提问人:Owen Lin 提问时间:8/21/2023 最后编辑:Brian Tompsett - 汤莱恩Owen Lin 更新时间:8/21/2023 访问量:23
如何使用 axios 从 API 获取错误消息的内容?
How to get the content of error message from API with axios?
问:
我正在研究 API 错误处理,通过使用 catch 错误方法,如果只能从我的 API 获取这些数据,而不能获取实际消息。
.catch(error => {
console.log(error.response.data);
});
我能得到的就是:
Blob {size: 14, type: 'application/json'}
size: 14
type: “application/json”
[[Prototype]]: Blob
如果我直接访问API,则无法收到以下消息:
“{”detail“:”签名无效“}”
有没有办法获取我在 react 中用 API 编写的实际消息?
顺便说一句,这不是 API 的问题。 令人惊讶的是,我确实得到了内容长度。
答: 暂无答案
评论