console.log("before")
function g(p,callback){
callback('1')
}
g(1,(re)=>{
console.log(re);
})
console.log("after")
The result is before 1 after. How to make the function call async means the result should be before after 1 without setTimeout function
The usecase is like
I have one api call inside a function and sending response after the this function call.But because this function is called synchronously sending response is delayed.So i want to send response before api call
console.log("before callback")
apiRes.url = [url];
apimanager.callfunc(requestBody, apiRes,(err,success)=>{
console.log("success ",success)
console.log("inside callback");
});
console.log("after callback")
return response.json(someresponse)