I'm new to node.js and from the postman I'm making a post call to my node server which further makes a call to remote server. I'm using axios to make the call, the api is return something like this :
exports.fetchFromRemoteServer = function(req, res, next){
const query = req.query;
axios({
method: 'post',
url: 'http://www.someUrl.com',
params: query
}).then(function(response){
console.log(response);
res.send('data', response);
}).catch(err => console.log(err));
}
Whenever I'm making this call, I get the data on the node server but I don't know how to make that async so that whenever it comes in the .then
of the api call res.send
start working. The postman keep showing me the loading state.
via Ajay Gaur
No comments:
Post a Comment