I have a promise that I'm trying to await but it is not working.
Here's my method:
async function lookupAndAddManager(id, record, fieldNameToAdd) {
console.log(`Searching ${id}`);
let promise = ups.getSearchResults(ups.Environment.Prod, ups.SearchConfig.Email, ups.emailFromId(id))
console.log("Promise", promise)
let response = await promise;
}
I'm calling it like this:
lookupAndAddManager(row.BPO, row, 'BPO_MGR')
My output is:
Searching CN=Name/OU=TEST/O=EXAMPLE
Promise Promise { }
However, the method is returning right away, the await promise
does not wait for the promise to be resolved.
Why not?
The method I'm calling is also async:
export const getSearchResults = async (env: Environment, searchConfig: SearchConfig, query: string): Promise<ISearchResult> => {
return new Promise((resolve, reject) => {
... resolve/reject as appropriate ...
});
};