8p / EightPointsGuzzleBundle

⛽️ Integrates Guzzle 6.x, a PHP HTTP Client, into Symfony
MIT License
440 stars 71 forks source link

Can't get Content of the Body using this Bundle #43

Closed grzegorztomasiak closed 8 years ago

grzegorztomasiak commented 8 years ago
    $client = $this->get('guzzle.client.api');
    $response = $client->get('/api/users);
    var_dump($response->getBody()->getContents()); //empty

    $client = new \GuzzleHttp\Client();
    $res = $client->request('GET', 'http://local.project/api/users');
    var_dump($res->getBody()->getContents()); //gives content

If I do request using Guzzle Client it works, but when I use the bundle request it does not work, hoewever in the profiler it works.. what could be the problem?

GCalmels commented 8 years ago

Hey, I think it's because you have to deserialize the body :

$client = $this->get('guzzle.client.api');
$response = $client->get('/api/users);
\Doctrine\Common\Util\Debug::dump(json_decode($response->getBody()));

It should work!

grzegorztomasiak commented 8 years ago

Wow, it really does work :) Thanks man! I think this should be documented somewhere...