📜  axios try catch 获取错误状态 cocxe - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:47.288000             🧑  作者: Mango

代码示例1
try {
         await axios.get('/bad-call')
     } catch (error) {
        const err = error as AxiosError
        if (err.response) {
           console.log(err.response.status)
           console.log(err.response.data)
        }
        this.handleAxiosError(error)
     }