title: node Cannot read property 'forEach' of undefined
body: <p>I get this error and i cant find the solution my code is proper i think it s video lesson where i can show popular photos from instaram via instagra api but i get this when i try to execute the node is running properly i can t understand my mistake</p>
  
  <pre><code>TypeError:\Desktop\instagramApp\views\pages\index.ejs:13
     11| &lt;main&gt;
     12| &lt;div class="row"&gt;
  &gt;&gt; 13| &lt;% grams.forEach(function(gram)  { %&gt;
     14| &lt;div class="instagram-pic col-sm-3"&gt;
     15| &lt;a href="&lt;%= gram.link %&gt;"target="_blank"&gt;
     16|  &lt;img src="&lt;%= gram.images.standard_resolution.url %&gt;" class="img-responsive"&gt;
  
  Cannot read property 'forEach' of undefined
     at eval (eval at &lt;anonymous&gt; (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\ejs\lib\ejs.js:464:12), &lt;anonymous&gt;:23:13)
     at returnedFn (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\ejs\lib\ejs.js:493:17)
     at View.exports.renderFile [as engine] (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\ejs\lib\ejs.js:350:31)
     at View.render (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\express\lib\view.js:126:8)
     at tryRender (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\express\lib\application.js:639:10)
     at EventEmitter.render (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\express\lib\application.js:591:3)
     at ServerResponse.render (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\express\lib\response.js:961:7)
     at C:\Users\Kel3vra\Desktop\instagramApp\server.js:24:7
     at handle_error (C:\Users\Kel3vra\Desktop\instagramApp\node_modules\instagram-node\lib\instagram.js:255:14)
     at C:\Users\Kel3vra\Desktop\instagramApp\node_modules\instagram-node\lib\instagram.js:904:16 
  </code></pre>
  
  <p>this the code of index.ejs</p>
  
  <pre><code>     &lt;!DOCTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
          &lt;% include ../partials/head %&gt;
          &lt;title&gt;&lt;/title&gt;
      &lt;/head&gt;
      &lt;body class="container"&gt;
          &lt;header&gt;
          &lt;% include ../partials/header %&gt;
          &lt;/header&gt;
          &lt;main&gt;
          &lt;div class="row"&gt;
          &lt;% grams.forEach(function(gram)  { %&gt;
              &lt;div class="instagram-pic col-sm-3"&gt;
              &lt;a href="&lt;%= gram.link %&gt;"target="_blank"&gt;
                &lt;img src="&lt;%= gram.images.standard_resolution.url %&gt;" class="img-responsive"&gt;
              &lt;/a&gt;
              &lt;/div&gt;
  
              &lt;div class="instagram-bar"&gt;
                  &lt;div class="likes"&gt;
                  &lt;span class="glyphicon glyphicon-heart"&gt;&lt;/span&gt;
                  &lt;%= gram.likes.count %&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;div class="comments"&gt;
              &lt;span class="glyphicon glyphicon-comment"&gt;&lt;/span&gt;
                  &lt;%= gram.comments.count %&gt;
              &lt;/div&gt;
            &lt;%  }); %&gt;
  
  
           &lt;/div&gt;
          &lt;/main&gt;
  
          &lt;footer&gt;
          &lt;% include ../partials/footer %&gt;
          &lt;/footer&gt;
      &lt;/body&gt;
  
      &lt;/html&gt;
  </code></pre>
  
  <p>and to my server.js</p>
  
  <pre><code>var express = require('express');    
  var app = express();
  var instagram = require('instagram-node').instagram();
  
  app.use(express.static(__dirname + '/public'));    
  app.set('view engine', 'ejs');
  
  instagram.use({
    client_id: /************/,
    client_secret: /*************/
  });
  
  app.get('/',function (req, res) {
    instagram.media_popular(function (err, medias, remaining, limit) {
      res.render('pages/index',{ grams: medias });
    });
  });
  
  app.listen(8080, function (err) {
    if(err) {
      console.log("error");
    } else {
      console.log("Listening on port 8080")
    }
  });
  </code></pre>