Promise.all 应用

122 阅读1分钟
const allTypes = ['location', 'media-stream-camera', 'media-stream-mic', 'notifications', 'clipboard'];
const promises = allTypes.map(item => websiteGetExceptionList(item));
const allTypeData = (await Promise.all(promises)).flat();

async function websiteGetExceptionList(type) {
    const res = await cr.sendWithPromise('getExceptionList', type)
    // return res.filter(v => v.setting === "allow");
    return res
}