Currently, I am facing an issue with a downstream API call that is returning a Promise object instead of resolving it immediately.
This is how I am making the downstream call:
const response = testClient.getSession(sessionId);
When I console.log(response)
, it displays Promise { <pending> }
rather than the expected result from the downstream.
I have limited knowledge about Async/Await and Promises. Can someone clarify which category this falls into? And how can I execute the promise first before proceeding with the remaining steps?
My current workaround involves using:
response.then(function(result) {
console.log(result.body);
});
However, I would prefer to store the result in the response object immediately after the call. Any guidance on this would be appreciated. Thank you.