Async/Await with for loop | await is only valid in async function

As a follow-up to my comment: verifyExistingUsers has no reason to 'return new promise'. Node will wrap your return statement in a promise on its own because the function is 'async'.

The original error here is because you effectively cannot use await in the anonymous, non-async function, ((resolve, reject) => {}).

Instead of returning a new promise, you will just return the variable you want when you are done pushing data into the array. By doing so and declaring the function as 'async', Node will wrap your return value in a promise that you await somewhere else.

async function verifyExistingUsers(db, users) {
       var companies = []
       for (const [index, user] of users.entries()) {

           let company = await getUserCompany(db, user)
           companies.push(company) 

           if (index === users.length-1) {
               return companies; //effectively returns a promise that resolves to companies
           }
       }
}