title: Uncaught TypeError: Cannot read property 'total' of undefined
body: <p>I get a JSON from my response object so I do:</p>
  
  <p><code>var json = JSON.parse(res.text);
  </code></p>
  
  <p>I print the JSON and get JSON back. But when I retrieve the value inside <code>json.body.value.total</code> then it gives this error:</p>
  
  <pre><code>Uncaught TypeError: Cannot read property 'total' of undefined
  </code></pre>
  
  <p>I have no idea why. I pasted the value that receive from var json and printed on console and was able to retrieve total. But I cannot do it through the code. There is a JSON value total. Its just unable to recognize. On the console, it works but does not work in the code.</p>
  
  <p>I get JSON back from my response object which I retrieve using <code>response.text</code>. I think it needs to change in parsable object but all it returns is <code>undefined</code></p>
  
  <pre><code>it('returns http 200', function (done) {
          chai
          .request(baseUrl)
          .get('/api/')
          .set('Authorization', 'Basic abc')
          .query({val:'hey'})
          .end(function(err, res) {
              expect(res).to.have.status(200);
  
              var json = res.text;
  
              console.log('val: '+ JSON.parse(json.body));
              var val = json.body.value.total; //undefined
              expect(val.to.be.above(0)); //fails
              done();
          });
      });
  </code></pre>