响应处理

PPG007 ... 2021-12-26 Less than 1 minute

# 响应处理

# 响应内容

请求正确后的响应对象内容:

{
    data:{},
    status:200,
    statusText:'OK',
    headers:{},
    config:{},
    request:{}
}
1
2
3
4
5
6
7
8

请求错误后 error 中的内容:

error.response
error.request
error.message
error.config
1
2
3
4

# 不使用拦截器处理

axios.get('/demo', {headers: {'token': "token"}})
    .then((res) => {
        // 请求成功
        console.log(res.data);
    }).catch((err) => {
        // 请求失败
        console.log(err.response.status);
    })
1
2
3
4
5
6
7
8
Last update: December 26, 2021 02:53
Contributors: PPG007