title: How to return Guzzle JSON response
body: <p>I am using Guzzle to make a aSync request that returns JSON. The call is working fine and the response is ok, however:</p>
  
  <pre><code>$client = new Client();
      $promise = $client-&gt;requestAsync($requestType ,$this-&gt;url.$resource, // endpoint
          [
              'auth' =&gt; [ // credentials
                  $this-&gt;username, 
                  $this-&gt;password
              ],
              'json' =&gt; $payload, // the package
              'curl' =&gt; [ // some curl options
                  CURLOPT_HTTPAUTH =&gt; CURLAUTH_BASIC,
                  CURLOPT_RETURNTRANSFER =&gt; true,
              ],
              'headers' =&gt; [ // custom headers
                  'Accept' =&gt;  'application/json',
                  'Content-Type' =&gt; 'application/json'
              ]
          ]
      );
  
      $response = $promise-&gt;wait();
      echo $response-&gt;getStatusCode().'&lt;br /&gt;&lt;br /&gt;';
      // Error handling
      if($response-&gt;getStatusCode() != 200){
          // Error Handling
      }else{
          echo $response-&gt;getBody(true);
      }
  </code></pre>
  
  <p>if I echo response->getBody() I see the JSON string, but if I assign it to a property, print_r, or return it I get:</p>
  
  <pre><code>GuzzleHttp\Psr7\Stream Object ( [stream:GuzzleHttp\Psr7\Stream:private] =&gt; Resource id #245 [size:GuzzleHttp\Psr7\Stream:private] =&gt; [seekable:GuzzleHttp\Psr7\Stream:private] =&gt; 1 [readable:GuzzleHttp\Psr7\Stream:private] =&gt; 1 [writable:GuzzleHttp\Psr7\Stream:private] =&gt; 1 [uri:GuzzleHttp\Psr7\Stream:private] =&gt; php://temp [customMetadata:GuzzleHttp\Psr7\Stream:private] =&gt; Array ( ) )
  </code></pre>
  
  <p>I need to use the JSON to validate my response from the service. How can I do this? I have gone through the docs, but am I obviously missing something.</p>
  
  <p>Essentially along the lines of assigning the json getBody output to say $json:</p>
  
  <pre><code>if($json-&gt;first_field &gt; 0)
  </code></pre>
  
  <p>Any Help appreciated. 
  Regards</p>