Laravel Request return array instead of value

129 Views Asked by At

i have Laravel project, i created a post route on api.php, that just returning data that i send:

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::post('client', fn(Request $req) => response()->json($req->key));

i send an object by axios { "key" : "test" } so i expected the code above to return me just string "test" so can i use it with Model::where(). but it return me an object:

{
    "__v_isShallow": false,
    "dep": {
        "w": 0,
        "n": 0
    },
    "__v_isRef": true,
    "_rawValue": "test",
    "_value": "test"
}

i always use $req->anykey and its work but i don't know what's happen this time, any help pleas.

UPDATE 1

i tried $req->input('key') same response.

0

There are 0 best solutions below