Security News
How Threat Actors are Abusing GitHub’s File Upload Feature to Host Malware
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
@prequest/error-retry
Advanced tools
Readme
错误重试中间件
npm install @prequest/error-retry
import { create } from '@prequest/xhr'
import errorRetryMiddleware from '@prequest/error-retry'
const prequest = create()
import { prequest } from '@prequest/xhr'
import errorRetryMiddleware from '@prequest/error-retry'
const middleware = errorRetryMiddleware({
// 错误重试次数
retryCount: 2,
// opt 为 Request 类型,通过该函数,你可以控制那些接口需要错误重试
retryControl(opt, e) {
const { method, path } = opt
// 如果是具体某个错误,则不进行重试
if (e.message === 'internal error') return false
// api 路径不进行错误重试
if (path === '/api') return false
// 只有 get 方法才进行错误重试
return method === 'GET'
},
})
prequest.use(middleware)
注册错误重试中间件后,每一个请求也可以单独配置错误请求次数
prequest('/api', { errorRetry: 1 })
Option Name | Type | Default | Required | Meaning |
---|---|---|---|---|
retryCount | number | 1 | false | 错误重试次数 |
retryControl | (opt: RequestOpt, e: Error) => boolean | (opt: RequestOpt) => opt.method === 'GET' | false | 重试策略,默认 get 请求会进行错误重试 |
FAQs
The npm package @prequest/error-retry receives a total of 5 weekly downloads. As such, @prequest/error-retry popularity was classified as not popular.
We found that @prequest/error-retry demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub is susceptible to a CDN flaw that allows attackers to host malware on any public repository.
Security News
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.