这可能看起来很愚蠢,但是当Axios中的请求失败时,我正试图获取错误数据.
axios.get('foo.com')
.then((response) => {})
.catch((error) => {
console.log(error) //Logs a string: Error: Request failed with status code 404
})
Run Code Online (Sandbox Code Playgroud)
而不是字符串,是否可以获得具有状态代码和内容的对象?例如:
Object = {status: 404, reason: 'Not found', body: '404 Not found'}
Run Code Online (Sandbox Code Playgroud)