title: convert response retuned by Guzzle client into json array
body: <pre><code>$repo=new \GuzzleHttp\Client(['headers' =&gt;['Accept'     =&gt; 'application/json',
                     'Content-Type'     =&gt; 'application/json',
                     'Authorization'  =&gt; 'Bearer '.$token,
                  ]);
  $promise = $repo-&gt;get('https://api.github.com/user');
  $results = json_decode((string)$promise-&gt;getBody(),true);
  
  
  
  
  array:30 [
    "login" =&gt; "Saurabh0707"
    "id" =&gt; 21239898
    "avatar_url" =&gt; "https://avatars2.githubusercontent.com/u/21239898?v=4"
    "gravatar_id" =&gt; ""
    "url" =&gt; "https://api.github.com/users/Saurabh0707"
    "html_url" =&gt; "https://github.com/Saurabh0707"
    "followers_url" =&gt; "https://api.github.com/users/Saurabh0707/followers"
    "following_url" =&gt; "https://api.github.com/users/Saurabh0707/following{/other_user}"
    "gists_url" =&gt; "https://api.github.com/users/Saurabh0707/gists{/gist_id}"
    "starred_url" =&gt; "https://api.github.com/users/Saurabh0707/starred{/owner}{/repo}"
    "subscriptions_url" =&gt; "https://api.github.com/users/Saurabh0707/subscriptions"
    "organizations_url" =&gt; "https://api.github.com/users/Saurabh0707/orgs"
    "repos_url" =&gt; "https://api.github.com/users/Saurabh0707/repos"
    "events_url" =&gt; "https://api.github.com/users/Saurabh0707/events{/privacy}"
    "received_events_url" =&gt; "https://api.github.com/users/Saurabh0707/received_events"
    "type" =&gt; "User"
    "site_admin" =&gt; false
    "name" =&gt; "Saurabh Verma"
    "company" =&gt; "Software-Incubator"
    "blog" =&gt; "https://github.com/orgs/Software-Incubator/dashboard"
    "location" =&gt; "Ghaziabad, India"
    "email" =&gt; null
    "hireable" =&gt; null
    "bio" =&gt; null
    "public_repos" =&gt; 6
    "public_gists" =&gt; 0
    "followers" =&gt; 0
    "following" =&gt; 0
    "created_at" =&gt; "2016-08-25T11:01:02Z"
    "updated_at" =&gt; "2017-09-11T03:35:05Z"
  ]
  </code></pre>
  
  <p>I am unable to convert it into proper json. 
  I am unable to access value against login key in the returned PHP stream. I m also unable to convert it into json.
  How can I access it?
  I have tried: </p>
  
  <pre><code>$results = json_decode((string)$promise['login]-&gt;getBody(),true);
  </code></pre>
  
  <p>but it is not valid.</p>