我正在尝试通过向邮递员发送api请求来注册用户,但响应中出现400错误的请求错误,我尝试了几件事,但无法解决。
请帮帮我。
registerController.php
if (User::where('email', $request->email)->where('role_id', $request->role)->exists()) {
return $this->errorResponse('User is already exists in our system, please try with different email addres', 409);
} else {
// return $request->all();
$user = $this->create($request->all());
$http = new Client;
$response = $http->post(\Config::get('app.url') . '/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => env('PASSWORD_CLIENT_ID'),
'client_secret' => env('PASSWORD_CLIENT_SECRET'),
'username' => $request->get('email'),
'password' => $request->get('password'),
'remember' => false,
'scope' => '',
],
]);
return $this->successResponse([
'token_data' => json_decode($response->getBody()),
'user' => [
'email' => $user->email
]
]);
}