1. 首页
  2. 移动开发
  3. 其他
  4. p retry:重试返回承诺或异步功能 源码

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

上传者: 2021-04-07 02:07:27上传 ZIP文件 8.68KB 热度 11次
重试 重试返回承诺或异步功能 它执行指数补偿,并支持失败操作的自定义重试策略。 安装 $ 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
下载地址
用户评论