axios访问资源时,响应的状态码是404的情况下,如何获取到响应体?

Axios访问资源时,响应的状态码是404的情况下,如何获取到响应体?

阅读 3.2k
2 个回答
axios.get(`url`)
    .then(function (res) {
        console.log(res.data);
    })
    .catch(function (err) {
        // err.response 里面有的
        console.error(err.response);
    })

返回的error里 包含了的,

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进