We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我在 request的拦截器给每个请求加上了cancelToken
function addPending(config) { const pendingKey = getPendingKey(config); config.cancelToken = config.cancelToken || new Reqs.CancelToken((cancel) => { if (!pendingMap.has(pendingKey)) { pendingMap.set(pendingKey, cancel); } }); } async function errHandler(response: Response, options: RequestOptionsInit, resJson: any) { const res = resJson ? resJson : await response?.clone?.()?.json?.() || {} console.log('isCancel', Reqs.isCancel(options), options) if(Reqs.isCancel(options.cancelToken)){ console.log('Request canceled', options.message); return } }
在response的时候 调用isCancel方法判断, 但每次都返回的false, 查看源码后,发现isCancel方法是判断传入的对象是否有__CANCEL__这个属性, 且__CANCEL__ == true
如上截图,传参是否应该为 .cancelToken.promise
The text was updated successfully, but these errors were encountered:
t通过查阅文档,发现isCancel 方法,应该放在errorHandler 异常处理函数里面
const errorHandler = (error: { response: Response , request}) => { const { response, request } = error if(Reqs.isCancel(error)) {} }
Sorry, something went wrong.
No branches or pull requests
我在 request的拦截器给每个请求加上了cancelToken
在response的时候 调用isCancel方法判断, 但每次都返回的false, 查看源码后,发现isCancel方法是判断传入的对象是否有__CANCEL__这个属性, 且__CANCEL__ == true
如上截图,传参是否应该为 .cancelToken.promise
The text was updated successfully, but these errors were encountered: