yatsenkolesh / instagram-nodejs

Simple library for auth, get followers, search by hashtags and locations, like posts, follow, get user feed of instagram with nodejs
MIT License
317 stars 74 forks source link

ReferenceError: sessionID is not defined #53

Open sscaetite opened 5 years ago

sscaetite commented 5 years ago

I had this issue when run the basic code:

ReferenceError: sessionID is not defined at Instagram.auth.then (C:\Users\samuc\projetos\instabot\app.js:25:21) at process._tickCallback (internal/process/next_tick.js:68:7)

My complete code:

const express = require('express');
const app = express();

let Instagram = require('instagram-nodejs-without-api');
Instagram = new Instagram();

let idOfSession = "Random, only for tests";
let csrfTokenOfSession = "Random, only for tests";

Instagram.getCsrfToken()
    .then((csrf) =>
    {
        Instagram.csrfToken = csrf;
        csrfTokenDaSessao = csrf;
        console.log(csrf);
        console.log(csrfTokenOfSession);
    })
    .then( () =>
    {

        return Instagram.auth('correctUser', 'correctPass')
            .then( (sessionId) =>
            {
                    Instagram.sessionId = sessionId
                    idDaSessao = sessionID;
                    console.log(sessionId);
                    console.log(idOfSession);
            });
    }) 
.catch(console.error);

app.listen(3000, () => {
    console.log("Running at port 3000")
});
lain-d commented 5 years ago

syntax error. It should be sessionId, not sessionID