I have build a Restful ApI and trying to access the API Data. So for that I have used Guzzlehttp for retrieving Data.Here is my Controller :
public function getApiValue()
{
$client = new Client();
$request = $client->request('GET', 'http://localhost/test/api/info');
$stream = $request->getBody();
$contents = $stream->getContents();
dd($contents);
}
Route:
Route::get('/showApiValue',[
'uses'=>'ItemController@getApiValue',
'as'=>'showApiValue'
]);
Here is my RestApi in api.php of other application
Route::get('/info',function(){
$user = User::all();
return $user;
});
But when I'm trying to access the URL I got empty array instead of getting the users data though I could get the data in that application with the above URL. Can anyone help me how could I get it?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire