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

后端 未结 6 1438
抹茶落季
抹茶落季 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 20:07

    I'm using try{} catch(e){} in NodeJs and found that simply adding Error() to the end of the function fixed the warning.

    Full code:-

    someArray.forEach(async (arrayValue) => {
        try {
            const prodData = await myAsyncFunc(arrayValue);
        } catch(e) {
            console.error(`Error: ${e}`);
        }
    }, Error());
    

提交回复
热议问题