3 回答
TA贡献1853条经验 获得超9个赞
只需在 function 关键字之前添加 async
unique.forEach(async function(uGroup) {
integromatArray = filteredPids.filter(pid => pid.fields.Group == uGroup)
console.log(uGroup, integromatArray);
switch(uGroup) {
case 'Birkenhead':
integromat_webhook_url = "https://hook.integromat.com/mksobdvdxxxxxxxxxxx?pidsArray=";
break;
case 'Taupo':
integromat_webhook_url = "https://hook.integromat.com/9c6y4279kxxxxxxxxxx?pidsArray=";
break;
}
const aj = JSON.stringify(integromatArray);
console.log('stringify array',aj);
await fetch(integromat_webhook_url + aj);
});
TA贡献1946条经验 获得超4个赞
我用这种方法让它按照我的一个朋友的建议工作......
console.log('Filtered PIDs:', filteredPids);
let worksheetsCreated = filteredPids.length;
let integromat_webhook_url = "";
if(worksheetsCreated > 0){
output.markdown(worksheetsCreated + " worksheets created and being sent to indiviudal groups.");
//ADD FILTERED PRODUCTION WORKSHEETS TO TABLE
let recordsCreated = await batchAnd('Create', groupworksheetsBase, filteredPids);
//GET ARRAY OF GROUPS IN FILTERED PRODUCTION WORKSHEET
const unique = [...new Set(filteredPids.map(item => item.fields.Group))];
console.log('unique groups in filtered PIDs', unique);
//LOOP THROUGH UNIQUE GROUPS
await Promise.all(
unique.map(async uGroup => {
integromatArray = recordsArray.filter(pid => pid.fields.Group == uGroup);
console.log(uGroup, integromatArray);
switch (uGroup) {
case 'Birkenhead':
integromat_webhook_url = 'https://hook.integromat.com/mksobdvdu8uydiq9x22mxptgaye6ueji?pidsArray=';
break;
case 'Taupo':
integromat_webhook_url = 'https://hook.integromat.com/9c6y4279kydmqm7hswjutwhp7fu814aa?pidsArray=';
break;
}
const aj = JSON.stringify(integromatArray);
console.log('stringify array', aj);
console.log('url',integromat_webhook_url + aj);
const result = await fetch(integromat_webhook_url + aj);
return result;
})
);
} else {
output.markdown("No new worksheets to add.");
}
TA贡献1802条经验 获得超4个赞
将 forEach 循环更改为 for 循环,并且不要忘记将 async 关键字放在 function 关键字之前,例如:
async function test() { }
添加回答
举报