node.js - How do I access the instagram API with Express JS and Jade? -


i having trouble getting information instagram's api , sending jade rendered on front end.

app.route("/api") .get(function(req, res){     var url = "https://api.instagram.com/v1/users/1234/media/recent/?client_id=xxxx";      request(url, function(err, res, data){         console.log(json.parse(data));         // go here          res.render('show', {media : data});     });     // or here?     res.render('show', {media : data}); });       

i trying collect 10 images api path , send them jade. getting parsed response in terminal of several entries. having hard time figuring out how send multiple responses jade file, having jade file loop through them.

i know user id , client id in url variable not correct. if have alternate method using request(), open well.

so answering own question on one. rendering has inside of request() function. issue in callbacks. issue had "res" response .get , request() callback. when changed "res" in request() function "response" not getting issues anymore. jade file below well

app.route("/api2") .get(function(req, res){      var url = "https://api.instagram.com/v1/users/1234/media/recent/?client_id=xxxx";      request(url, function(err, response, body){         var datagram = json.parse(body);         res.render('show', datagram);     }); }); 

jade file:

each thing in data    h1 id : #{thing.id}    img(src="#{thing.images.thumbnail.url}")    a(href="#{thing.link}" target="_blank") link    h3 filter : #{thing.filter} 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -