Intellij Idea warning - “Promise returned is ignored” with aysnc/await

后端 未结 6 1537
抹茶落季
抹茶落季 2020-12-29 19:02

I\'m using Express.js in my code with Node.js v7.3. In this I\'ve created a User Router which forwards the requests to my User Controlle

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-29 19:48

    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.

提交回复
热议问题