我试图在循环数组(Vue 项目)中给 axios 延迟。
let promises = [];
for (const item of this.itemsWithIndex) {
const cmd = "od_kioskPaperUpdate";
promises.push(
await axios({
url: 'url',
method: 'post',
data: data
}).then((res) => {
if (res.statusText == 'OK') {
console.log('success', res)
} else {
console.log("failed", res)
}
})
.catch((err) => {
console.log(err)
})
)}
Promise.all(promises)
.then(async (r) => {
console.log(r)
}
Run Code Online (Sandbox Code Playgroud)
我如何每 3 秒调用一次 axios 函数?