Cannot read property 'forEach' of undefined
Opened this issue · 0 comments
saadi123 commented
I'm trying to create an APP using Instagram API. I've generated valid authorization token but it gives me an error: Cannot read property 'forEach' of undefined whenever I try to run the nodejs code.
The code is like this:
var express = require('express');
var bodyParser = require('body-parser');
//Create an express app
var app = express();
//grab instagram package
var ig = require('instagram-node').instagram();
//tell node where to look for resources
app.use(express.static(__dirname + '/public'))
//set view engine to ejs
app.set('view engine', 'ejs');
app.get('/', function(req, res, next){
ig.use ({
access_token: 'My-Token',
/*client_id: 'MY-ID',
client_secret: 'MY-SECRET-ID'*/
});
ig.media_popular(function(err, medias, remaining, limit){
//if (err) return next(err);
res.render('pages/index', {grams: medias});
});
});
app.listen(8080);
console.log("The app started and the server is up and running...");```
However, when I try to generate the error by adding lines like:
`if (err) return next(err);`
It gives the following error: Error: APINotFoundError: invalid media id
What does it even mean? I mean I haven't entered any media ID.
Kindly help me.