I'm using the 500px API module with Node.js and I'm trying to get photos of a specific user. I'm facing issue with function, callback and scope... I've this code :
api500px.photos.getByUsername ('username', {'sort': 'created_at', 'image_size': '3'}, function(error, results) {
if (error) {
console.log(error);
return;
}
var dataPx = results.photos;
});
I want to get out my variable dataPx and use it in my ejs template :
app.get('/materialize', function(req, res) {
res.render('materialize.ejs', {dataPx: dataPx});
});
If someone could explain me how to do that and how this kind of things work in JavaScript it would be cool !!!
Thx