p retry:重试返回承诺或异步功能 源码

spatial39191 10 0 ZIP 2021-04-07 02:04:26

重试 重试返回承诺或异步功能 它执行指数补偿,并支持失败操作的自定义重试策略。 安装 $ npm install p-retry 用法 const pRetry = require ( 'p-retry' ) ; const fetch = require ( 'node-fetch' ) ; const run = async ( ) => { const response = await fetch ( 'https://sindresorhus.com/unicorn' ) ; // Abort retrying if the resource doesn't exist if ( response . status === 404 ) { throw new pRetry . AbortError ( response . statusText ) ; } retur

用户评论
请输入评论内容
评分:
暂无评论