title: How to handle JSON response in Nightmare.js
body: <p>Interested to know if there is a better or another way to handle URLs that contain only JSON data <strong>using Nightmare.js</strong> than using <code>document.querySelector('*').textContent</code> within .evaluate? </p>
  
  <p>Here is an example; the external URL here contains the following which is the contents of a linked select field</p>
  
  <pre><code>{
    "baseDeliveryModelId":1,
    "county": [
       {"id": "1000706000", "label": "Çukurova", "value": "Çukurova"},
       {"id": "1000707000", "label": "Sarıçam", "value": "Sarıçam" },
       {"id": "1000922000", "label": "Seyhan", "value": "Seyhan"}, 
       {"id": "1000921000", "label": "Yüreğir","value": "Yüreğir"}
    ], 
    "listType":"DISTRICT_LIST"
  }
  </code></pre>
  
  <p>A sample.js code to retrieve just the county data from the URL <em>(which works fine)</em> </p>
  
  <pre><code>const Nightmare = require('nightmare'),
      vo = require('vo'),
      nightmare = Nightmare({show: true});
  
  
  function counties(city) {
      let countyUrl = `https://www.sanalmarket.com.tr/kweb/getCityDeliveryLocation.do?shopId=1&amp;locationId=${city}&amp;locationType=city&amp;deliveryTypeId=0`;
      return nightmare
          .goto(countyUrl)
          .evaluate(function() {
              return (JSON.parse(document.querySelector('*').textContent)).county;
          })
          .catch(function (err) {
              console.log('Error: ', err);
          });
  }
  
  
  vo(function* () {    
      return yield counties('01');    
  })((err, result) =&gt; {    
      if (err) return console.log(err);
      console.log(result);    
  });
  </code></pre>
  
  <p>Note: The question is about using <strong>Nightmare.js</strong>, or using other libraries <strong>with Nightmare.js</strong> in node.js for handling JSON responses, I am fully aware and capable of using other libraries such as axios.js on their own to solve the above. </p>