I'm making a Laravel 5.2 project which is communicating with a local API. And I'm having issues handling the Guzzle response body.
My controller:
public function getClients(){
$guzzle = new Client();
try{
$response = $guzzle->request('GET', 'http://localhost:3000/client')->getBody();
return view('home.clients', ['clients' => $response]);
}catch(ClientException $e){
//Handling the exception
}
}
My blade View:
<h2>Client list</h2>
{{ $clients }}//Just to inspect it
@forelse ($clients as $client)
<h3>{{ $client->name }}</h3>
<h3>{{ $client->email }}</h3>
<h3>{{ $client->country }}</h3>
@empty
<h3>No clients here</h3>
@endforelse
No errors on the loop or the controller, also is showing the Stream Object in the browser but in the loop doesn't display anything.
I've already read the Guzzle 6 response body documentation, but it's not that clear for a newbie in this like me.
Thoughts?
Browser output: