Skip to content

配置request.interceptors.response.use后,errorHandler失效#53

Open
l745230 wants to merge 107 commits into
use/umi-lintfrom
master
Open

配置request.interceptors.response.use后,errorHandler失效#53
l745230 wants to merge 107 commits into
use/umi-lintfrom
master

Conversation

@l745230
Copy link
Copy Markdown

@l745230 l745230 commented Jun 23, 2019

测试发现未配置"5. For the status code is actually 200 errors," errorHandler能正常接收到404 500错误.
配置了request.interceptors.response.use后,errorHandler中error返回为underfind
image

clock157 and others added 30 commits February 16, 2019 19:07
refactor: use umi-plugin-library to bundle
doc: add doc vs axios and english readme.
send data for patch method
Add a parameter description for credentials in README.md file.
fix: index.d.ts 缺少 patch 方法定义
feat: Send data using delete
@luopeihai
Copy link
Copy Markdown

包一层 函数 同意处理 Response,绕过报错:

//包一层 处理返回
async function requestUmi(url, params: { method: 'GET' }): Response {
return await request(url, params).then(hasResponseError);
}

// 检测返回结果是否有错误
function hasResponseError(response) {
if (response.code !== 200) {
//codeMessage 为非 state 报错码,
const message = codeMessage[response.code] || response.message;
throw new Error(message);
}
return response;
}

export default requestUmi;

使用:
import request from '@/utils/request';
request(youpath, { method: 'DELETE' })
.then(function (response) {
message.success('删除成功,即将刷新');
return true;
})
.catch(function (error) {
message.error(error.message);
return false;
});

ttys026 and others added 14 commits May 19, 2021 15:15
因为 prefix 配置和 interceptor 内部都可以修改 url,而在后续的 interceptor 中难以将其还原。
在 options 中储存一下原始入参的 url 值,以便后续的 interceptor 读取。
* chore: switch build tool to father

* chore: use father-build instead of father

Co-authored-by: troy.lty <troy.lty@alipay.com>
* chore: remove abort controller polyfill

* test: update test case and remove AbortController export

* docs: update doc for abort controller
Co-authored-by: shiluo.dwt <shiluo.dwt@antgroup.com>
上传文件应当指定指定 requestType: 'form',文档示例缺少改部分代码
文件上传补充说明
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.