i am trying to get access token from api...but i am getting undefined json data pls help.. I got correct data in requestToken() but when it returns data to route.js..
access.js ----------------------------------------------------------------------------------------------------------------------
exports.requestToken = function () {
var options = {
url: '---URL---',
method: 'POST',
form: {
access_key: 'xxxxxx',
secret_key: 'xxxxxx',
app_id: 'xxxxx',
device_id: 'xxxxx'
}
};
request(options, function(error, res, body) {
//console.log(JSON.parse(body)) ---> correct data
//here s problem
return JSON.parse(body);
});
}
route.js -------------------------------------------------------------------------------------------------------------------------
route.get('/get', function(req, res)
{ //undefined
body = jsonBody.requestToken();
console.log(body);
body = jsonBody.reqRecentMatches(token);
//console.log(body);
//res.json(body);
}