title: JSON Object Undefined (Nodejs)
body: <p>I'm trying to access a JSON object but I'm getting errors while accessing the object. Could you please go through the code and let me know the mistake I'm making. </p>
  
  <p>I'm writing 2 different cases to give a better understanding about my problem</p>
  
  <p>Here's the JSON data:</p>
  
  <p><img src="https://i.stack.imgur.com/CGF5m.png" alt="JSON DATA"></p>
  
  <p><strong>Case 1:</strong> </p>
  
  <p>If I just try to access the company_base object, I'm getting the Undefined value </p>
  
  <pre><code>if(!error &amp;&amp; response.statusCode == 200){
    console.log("Insurance name is.....");
      var parsedData = JSON.parse(body);
      console.log(parsedData["company_base"]);
    }
  </code></pre>
  
  <p>Result:
  Insurance name is.....
  undefined</p>
  
  <p><strong>CASE 2:</strong></p>
  
  <p>I'm attaching 2 images. One contains the JSON text and the other contains the error I'm getting while trying to access the JSON object.</p>
  
  <p>//This is the Code I'm using to access the object</p>
  
  <pre><code>   if(!error &amp;&amp; response.statusCode == 200){
      console.log("Insurance name is.....");
      var parsedData = JSON.parse(body);
      console.log(parsedData["company_base"][""business_type"]);
     }
  </code></pre>
  
  <p>Insurance name is.....
  C:\Users\Ebbie\Desktop\Misc\mean\udemy\the web developer bootcamp\IntroToApis\CSG\app.js:37
          console.log(parsedData["company_base"]["business_type"]);
                                                ^</p>
  
  <blockquote>
    <p>TypeError: Cannot read property 'business_type' of undefined
        at Request._callback (C:\Users\Ebbie\Desktop\Misc\mean\udemy\the web developer bootcamp\IntroToApis\CSG\app.js:37:47)
        at Request.self.callback (C:\Users\Ebbie\Desktop\Misc\mean\udemy\the web developer bootcamp\IntroToApis\CSG\node_modules\request\request.js:186:22)
        at emitTwo (events.js:106:13)
        at Request.emit (events.js:191:7)
        at Request. (C:\Users\Ebbie\Desktop\Misc\mean\udemy\the web developer bootcamp\IntroToApis\CSG\node_modules\request\request.js:1081:10)
        at emitOne (events.js:96:13)
        at Request.emit (events.js:188:7)
        at IncomingMessage. (C:\Users\Ebbie\Desktop\Misc\mean\udemy\the web developer bootcamp\IntroToApis\CSG\node_modules\request\request.js:1001:12)
        at IncomingMessage.g (events.js:291:16)
        at emitNone (events.js:91:20)</p>
  </blockquote>