I am having a downstream API call which is basically returning a Promise object instead of resolving it and executing it on point. This is how I am calling the downstream:
const response = testClient.getSession(sessionId);
When I console.log(response)
it is prinitng as Promise { <pending> }
instead of desired result which it shoudl print from the downstream.
Having known very little about Async/Await, Promises etc I would like to know whihc category does it fall in? And how do I execute that promise first and do the rest of the steps.
However, I have found a temporary work around like this:
response.then(function(result) {
console.log(result.body);
});
But ideally I would want to store the result into response object then and there itself. Please help me understand this. Thanks in advance