Third console statement executes before the second one when i request to api to get response the other code start executing and i want to prevent this i'm new to javascript., i tryed async-await but i'm doing something wrong..!
app.post('/api', async (req, res) => {
console.log(req.body.msg+" -> "+req.body.user+" -> one");
options.qs.message=req.body.msg;
options.qs.uid=req.body.user;
let botRespone= await request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body+" -> two");
botRespone=body;
});
console.log(botRespone.chatbot+" -> three");
});