I'd like to make a POST request on a GET action.
Everything works but I can't see "TOKEN" after the post and I don't understand why.
var request = require('request');
exports.getToken = function(req, res){
var postData = {
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
grant_type: 'authorization_code',
redirect_uri: REDIRECT_URI,
code: CODE
}
request.post({
uri:"https://api.instagram.com/oauth/access_token",
form: postData,
followRedirect: true,
maxRedirects: 10
},function(err,res,body){
var data = JSON.parse(body);
TOKEN = data.access_token;
});
console.log(TOKEN);
res.render('index', {title: '*****'});
}