title: How to Retrieve HTTP Status Code with Guzzle?
body: <p>New to Guzzle/Http.</p>
  
  <p>I have a API rest url login that  answer with 401 code if not authorized, or 400 if missing values.</p>
  
  <p>I would get the http status code to check if there is some issues, but cannot have only the code (integer or string).</p>
  
  <p>This is my piece of code, I did use instruction here ( <a href="http://docs.guzzlephp.org/en/stable/quickstart.html#exceptions" rel="noreferrer">http://docs.guzzlephp.org/en/stable/quickstart.html#exceptions</a> )</p>
  
  <pre class="lang-php prettyprint-override"><code>namespace controllers;
  use GuzzleHttp\Psr7;
  use GuzzleHttp\Exception\ClientException;
  
  $client = new \GuzzleHttp\Client();
  $url = $this-&gt;getBaseDomain().'/api/v1/login';
  
  try {
  
      $res = $client-&gt;request('POST', $url, [
          'form_params' =&gt; [
              'username' =&gt; 'abc',
              'password' =&gt; '123'                     
          ]
      ]);
  
  } catch (ClientException $e) {
  
      //echo Psr7\str($e-&gt;getRequest());
      echo Psr7\str($e-&gt;getResponse());
  
  }
  </code></pre>