Within my code, I have an array containing different user names. My goal is to loop through each name, verify if the user exists in the database, and then create the user if necessary. However, my linter keeps flagging a message stating
'await' has no effect on the type of this expression
at specific locations that I've denoted:
await Promise.all(
userNames.map(async userName => {
const user = await users.findOne({ name: userNames });
if (!user)
await users.create({ // The linter highlights this bracket (Not the curly bracket)
name: userName,
}); // And also this closing bracket
}),
);
The suggestion from my text editor is as follows:
if (user) {
return;
}
await users.create({
name: userName,
});
This essentially reverses the if-else logic. Any thoughts on why this might be recommended?