I have two files where one.js has all modules and those modules are called in two.js file. But whenever I do get request, the function does not wait. I know node is asynchronous. Is there any way to handle the function without callbacks
//File one.js
function getRequest(){
var url = "https://api.hasoffers.com/v3/Affiliate_Affiliate.json";
request(url, function (err, reponse, value) {
return JSON.parse(value);
});
}
exports.getRequest = getRequest;
//File two.js
var one = require(one.js);
console.log(one.getRequest()); //Returns undefined
I need to call function in two.js file in the same way one.getRequest();
without any callback.