1

Got problem with changing value of variable test. Found this code for instagram private api, it works, but the problem is that I can't somehow save urls to images that are saved inside promise function in variable urls. I need this urls for further work. Please could you modify my code for it to display test correctly? I found common solutions on github but all of them like alert(result) console.log(result) and I need the result for futher work so I really wasnt able to find how to do that

'use strict';
var InstagramPrivateAPI = {};

InstagramPrivateAPI = {};
InstagramPrivateAPI.V1 = require(__dirname + '/client/v1');
InstagramPrivateAPI.Helpers = require(__dirname + '/helpers');
var acc = require(__dirname + "/client/v1/account");
var med = require(__dirname + "/client/v1/media")

var Promise = require('../bluebird');
var _ = require('../lodash/');

module.exports = InstagramPrivateAPI;

var Client = require('instagram-private-api').V1;
var device = new Client.Device('maksgmn');
var storage = new Client.CookieFileStorage(__dirname + '/cookies/maksgmn.json');

//var session = Client.Session.create(device, storage, 'maksgmn', '142857loN');
var session = new Client.Session(device, storage);

/*
acc.getById(session, '2336279210')
    .then(function(account) {
        console.log(account);
        // {username: "...", ...}
        //console.log(account.id);
        // only property which is exported as top level
        // property
    })
*/

var feed = new Client.Feed.UserMedia(session, '2336279210');

var test = ""

Promise.mapSeries(_.range(0, 1), function() {
    return feed.get();
})
.then(function(results) {
    // result should be Media[][]
    var media = _.flatten(results);
    var urls = _.map(media, function(medium) {
        return medium.params.imageVersions2.candidates[0].url
    });
    test = urls;
})

console.log(test)



/*
acc.searchForUser(session, 'maksgmn')
    .then(function(accou) {
        console.log(accou.id)
    })
*/


/*
med.getById(session, '1234567')
    .then(function(medInfo) {
        console.log(medInfo.params)
    })

*/

/*
acc.showProfile(session)
    .then(function(accr) {
        console.log(accr)
    })
*/

/*acc.search(session, 'maksgmn')
    .then(function(id) {
        console.log(id)
    })
*/
user239247
  • 51
  • 3

0 Answers0