动态重试执行函数
异步函数
最大重试次数
重试延迟时间(毫秒)
函数执行结果
const fn = async () => { await new Promise(resolve => setTimeout(resolve, 1000)) throw new Error('Failed') } const result = await retry(fn, 3, 1000) console.log(result) // Error: Failed 复制
const fn = async () => { await new Promise(resolve => setTimeout(resolve, 1000)) throw new Error('Failed') } const result = await retry(fn, 3, 1000) console.log(result) // Error: Failed
动态重试执行函数