title: Undefined response returned by Chakram requests
body: <p>I'm facing a strange problem in my automated tests written using Protractor. We need to test a bunch of API endpoints that return JSON over HTTP, as opposed to actual websites so instead of relying on Protractor, my team decided to use <a href="http://dareid.github.io/chakram/jsdoc/index.html" rel="nofollow noreferrer">Chakram</a>.</p>
  
  <p>I have a page object responsible for accessing the API:</p>
  
  <pre><code>const qs = require('querystring')
  const chakram = require('chakram');
  
  function MyApi() {
  
    const domain = // read from a configuration file
  
    this.readImportantBusinessData = (queryParams) =&gt; {
      const serviceUrl = `${domain}/services/seriousBusiness.json`;
      const queryString = qs.stringify(queryParams);
      const fullUrl = `${serviceUrl}?${queryString}`;
      return chakram.get(fullUrl).then((response) =&gt; {
        return response;
      });
    };
  };
  
  module.exports = new MyApi();
  </code></pre>
  
  <p>then, in one of my specs, I call the <code>readImportantBusinessData</code> function to check if it returns the expected data.</p>
  
  <pre><code>return MyApi.readImportantBusinessData(validParameters).then((response) =&gt; {
          chakramExpect(response).to.have.status(HTTP_200_OK);
          chakramExpect(response).to.have.json({
              "foo" : "bar"
          });
        });
  </code></pre>
  
  <p>Depending on the enviornment where I run this code,  the test passes or fails with an error message that basically means that no response has been received. </p>
  
  <pre><code>Failed: Cannot read property 'statusCode' of undefined
  </code></pre>
  
  <p>I can confirm that the server I'm hitting is running and I can get a correct response when using a web browser.</p>
  
  <p>The rquest made in my tests succeeds when I use a shared server hosted in AWS and fails when I use a local server running in VirtualBox.</p>
  
  <p>Why could Chakram not recieve a response at all?</p>