I am trying to get all users items from steam, so i need to use request module to get json file from steamcommunity. The problem is i don't know how to return that json to app.js and pass through routes.
var request = require('request');
var userItems = function(req, res){
var userItems = request('http://steamcommunity.com/profiles/'+req+'/inventory/json/730/2', function (error, response, body) {
if (!error && response.statusCode == 200) {
var info = JSON.parse(body);
return res(info);
}
});
}
module.exports.userItems = userItems;
Idea is next:
app.get('/account/:id', ensureAuthenticated, ensureID, function(req, res){
res.render('account', {
user: req.user,
items: userItems(req.params.id, res)
});
});
I am begginer, and i will learn from start, but for now i just need to work because i am short with the time. Thank you.