【发布时间】:2021-01-08 12:58:00
【问题描述】:
我有两个来自 eslint 的错误:
错误 Promise 在函数参数中返回,其中返回的是 void 预期错误 Promise 执行器函数不应该是异步的
它们来自以下代码:
const promiseFeature = new Promise(async (resolve) => {
let objectProfile = await this.userFeaturesRepository.findById(id);
objectProfile = await this.userFeaturesRepository.getProfileObj(myUserFeatures);
await this.userFeaturesRepository.updateById(id, objectProfile);
resolve()
})
const promiseIAM = new Promise(async (resolve) => {
let objectIAM = await this.userIAMRepository.findById(id);
objectIAM = await this.userIAMRepository.getIAMObj(myUserFeatures);
objectIAM.email = objectIAM.email.toLowerCase();
await this.userIAMRepository.updateById(id, objectIAM);
resolve()
})
await Promise.all([promiseFeature, promiseIAM]);
代码有效,但我真的不知道谁来解决 eslint 问题。
谢谢, 提前。
【问题讨论】: