my application nodejs + express must make requests to another server to build his answers. This request will be used a lot. I would like to put it in a module. I am using the requestjs module. I can build my query and get the right result in the console. But I can not incorporate this code into a module that I could call. There is a lot of example on handling incoming requests but few on outgoing requests. How should I build this module. I know how to do simple modules but not this one. This code does not work. Thanks for your help
var request = require("request") ;
request ("http://example.com", function(error, response, body) {
myInformation = JSON.parse (body) ;
mytoken = myInformation.token
console.log(mytoken);
});
exports.myTest = function () {
return myToken ;
};