mardi 8 novembre 2016

Laravel 5.3: GuzzleHttp returns empty array from API request

I have built a RestApi from there I wanted to get the expected Data. I have used GuzzleHttp on my Laravel Project. But when I try to access the data I got empty array. But if I do hard refresh like pressing F5 button continuously I got the data. I tried to run it in different server. same error I'm getting ..If anyone faced the error or could help me how to resolve it. There is no cache or session issue as I've checked in incognito mode also.

for accessing the data I've used following controller.

public function saveApiData()
                {
                    $client = new Client();
                    $res= $client->get('http://localhost/atom/public/api/user');
                   dd($res->getBody()->getContents());
    }

the other project's route from where I tried to access the data (api.php):

Route::get('/show',function(Request $request){
     $user = User::all(); 
    return $user;
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire