Skip to content

Cannot read property 'forEach' of undefined #119

@saadi123

Description

@saadi123

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. 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions