Intellij Idea warning - "Promise returned is ignored" with aysnc/await
The thing is I'm not even returning anything from the login() method.
A function declared "async" returns a Promise by definition. See for example https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
However the IDEA warning is only an inspection. You can press "alt-enter, right" on the warning and change the inspection level to make the warning go away. The inspection is in the "JavaScript -> Probable bugs" category and is named "Result of method call returning a promise is ignored".
The userController.login()
function returns a promise, but you're not doing anything with the result from the promise by utilizing its then()
function.
For example:
userController.login(req, res).then(() => {
// Do something after login is successful.
});
or in the ES2017 syntax:
await userController.login(req, res);
If you don't actually want to do anything there, I guess you can just ignore the warning. The warning is mostly there because not using the then()
function on a promise is usually a code smell.