[英]Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() with Axios Vue and Laravel 7
[英]Laravel - Argument 2 passed to Symfony\\Component\\HttpFoundation\\JsonResponse
我想将$users
的数据作为数组返回,并将$this->guard()->user()
作为不在数组内的数据返回。 我试过下面的给定。 但它会产生错误 - Argument 2 passed to Symfony\\\\Component\\\\HttpFoundation\\\\JsonResponse::__construct() must be of the type int, object given, called in C:\\\\wamp64\\\\www\\\\Laravel\\\\projects\\\\Content-Que-Laravel-API\\\\vendor\\\\laravel\\\\framework\\\\src\\\\Illuminate\\\\Http\\\\JsonResponse.php on line 32
。 我正在使用 Laravel-8 和 pgsql -13。 如何解决这个问题? 有什么建议么..
$users = DB::table('users')
->join('location', 'users.id', '=', 'location.id')
->join('user_technical_details', 'users.id', '=', 'user_technical_details.id')
->get();
return response()->json(['data' => $users],$this->guard()->user());
预期输出:
{
"id": 2,
"name": "mrt",
"email": "ba@f.com",
"phone": 1112223333,
"email_verified_at": null,
"OTP": null,
"ph_OTP": 6033,
"email_OTP": 1090,
"user_access_token": null,
"created_at": "2021-07-20T06:49:29.000000Z",
"updated_at": "2021-07-20T06:49:29.000000Z"
}
您可以通过如下结果,因为 jsonresponse 中的第二个参数是 http status(200, 401)。
return response()->json([
'data' => [
'users' => $users,
'guard' => $this->guard()->user()
]
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.