Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'forEach' of undefined #119

Open
saadi123 opened this issue Aug 21, 2017 · 0 comments
Open

Cannot read property 'forEach' of undefined #119

saadi123 opened this issue Aug 21, 2017 · 0 comments

Comments

@saadi123
Copy link

saadi123 commented Aug 21, 2017

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. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant