I have this route in api route file
Route::post('/user/register', 'HomeController@register');
and the register function is
public function register(Request $request)
{
$user = User::create([
...
]);
return $this->getAccessToken($request);
}
public function getAccessToken(Request $request)
{
$url = url('/oauth/token');
$headers = ['Accept' => 'application/json'];
$http = new Client;
$response = $http->post($url, [
'headers' => $headers,
'form_params' => [
'grant_type' => 'password',
'client_id' => 'my_client_id',
'client_secret' => 'my_client_secret',
'username' => 'username',
'password' => 'password'
],
]);
return json_decode((string)$response->getBody(), true);
}
now when I send post request to the url the user is created but the request keep loading and no response and the whole application is hanging until I close the IDE - phpstorm -
I send the same parameters to the same url /oauth/token
from postman and it works fine.
any help or any one tell me what I am missing ?
the problem was the curl do not work when the url contains port like
localhost:8000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With