I have an async function that waits for a promise:
const getUserByImportMail = async (mail) => {
const mailResult = await client.request(GET_COMPANY_BY_IMPORT_MAIL, mail)
console.log("In file 1: " + inspect(mailResult))
return mailResult
}
and another function in another file which does some checks on it:
const isSenderValid = mail => {
const importMail = getUserByImportMail({importMail: mail})
console.log("In file 2: " + inspect(importMail))
// some checks
return importMail
}
I always thought that async functions will wait for the Promise to resolve which they do, kinda:
// In file 1: { companies: [{obj}] }
but
// In file 2: Promise { <pending> }
Why is execution continued for isSenderValid
and not being wait for the Promise to resolve, and how to fix it?