Axios未在401错误响应上写入状态401

时间:2019-05-21 13:30:40

标签: javascript reactjs axios

我正在尝试在axios的错误回调中捕获401错误(我只是想检测到这是401错误),但是它没有任何指示401的属性。

即-

test401() {
    var self = this;
    axios.post('https://mail.google.com/sync/u/0/i/fd?hl=en&c=12')
    .catch( (error) => {
        self.setState({data: error.status || "No Status" });
      console.log("catch ", error); // No any status here
    });
}

如果要检查,这里是jsfiddler

我怎么能在axios中知道我收到401错误响应?

0 个答案:

没有答案
相关问题