title: JSON loop a multidimensional array to with node.js
body: <p>Having read up on different methods please bear with me to try to explain.  </p>
  
  <p>I am trying to retreive data from the twitch api and loop the user.name results to an array possibly inside an object.  I am using nodejs so it has to be javascript.</p>
  
  <p>So far when I run the following I get a nice json response.</p>
  
  <pre><code>var request = require('request');
  
      request({url: 'https://api.twitch.tv/kraken/channels/twitch/follows?limit=3'}, function(err, res, json) {
          if (err) {
              throw err;
          }
  
          console.log(json);
  
      });
  </code></pre>
  
  <p>this then logs the same as if one where to visit <a href="https://api.twitch.tv/kraken/channels/twitch/follows?limit=3" rel="nofollow noreferrer">https://api.twitch.tv/kraken/channels/twitch/follows?limit=3</a></p>
  
  <p>or better visualized as </p>
  
  <p><img src="https://i.stack.imgur.com/MjTm2.png" alt="json structure"></p>
  
  <p>Now I want to select the follows -> user -> name object.  More so, loop every user -> name in the response. </p>
  
  <p>I thought I would need to convert the string to an object so I tried</p>
  
  <pre><code>    var obj = JSON.parse(json);
  </code></pre>
  
  <p>but that only returns the first {3} objects in the tree.  So I went ahead and tried</p>
  
  <pre><code>var request = require('request');
  
      request({url: 'https://api.twitch.tv/kraken/channels/twitch/follows?limit=3'}, function(err, res, json) {
          if (err) {
              throw err;
          }
  
          for (var i=0; i&lt;json.length; i++) {
  
          var obj = JSON.parse(json.follows[i].user.name);
          console.log(obj);
  
          }
  
      });
  </code></pre>
  
  <p>and it returns </p>
  
  <pre><code>TypeError: Cannot read property '0' of undefined
  </code></pre>
  
  <p>For testing purposes I also got rid of the loop and just have <a href="https://i.stack.imgur.com/MjTm2.png" rel="nofollow noreferrer">1</a> to return one bit of info.  Having tried multiple instances of rearranging the call I always get either an error or "undefined" back.</p>
  
  <p>Nothing seems to work, I am even going about this the right way?</p>