I am using requsts package to call api from another server. But the global variable outside the function is not getting updated and showing undefined.
var request = require('request');
var contractAddress;
var abi;
request('http://expressanthem:9000/getcontractAddress',function(error,response,body){
contractAddress=body;
console.log(contractAddress+" "+"contract address at first");
});
request('http://expressanthem:9000/getcontractAbi',function(error,response,body1){
// contract=body1;
// console.log(typeof contract);
abi=body1;
console.log(abi+" "+"This is the abi at first");
});
console.log("The contractAddress is"+" "+contractAddress);
console.log("The cotractABI is"+" "+abi);
module.exports={
contractAddress,
abi
};
The global varibale ABI and contract address is giving values undefined.