javascript - 发布请求失败后无法捕获响应
问题描述
我发送这样的请求
try {
const res = await axios.post('/order', formData)
console.log(res) --> undefined
console.log(test1) --> it is on console
}
catch (error) {
console.log(test2)
}
但由于某种原因,即使我从请求中得到 500,test1 和 undefined 也在控制台上。为什么会发生这种情况,即使它是一个错误。不应该去抓吗?
- - 解决方案 - -
4天后我发现了问题所在。从代码中删除 axios.interceptor 后,一切都按预期工作
解决方案
推荐阅读
- powershell - 如果 VLAN 尚未启用,则启用 VLAN 并使用 powershell 脚本设置 VLAN ID
- java - URLConnectionReader 产生 UnknownHostException
- python - 扩展原始 roi 后如何在新图像中找到 roi 位置?
- postgresql - 一个查询中有多个 ON CONFLICT
- video - 即使录制意外中断(例如断电),如何在 gstreamer 中录制可播放的视频文件?
- javascript - 如何在材质 UI 中重置 getTagProps?
- sql-server - 通过 MSSQL 连接到 Lotus NSF 文件
- reactjs - 从 React js 应用程序验证和访问受 Spring Security 保护的 API
- clang - `Uninitialized value was created by a heap deallocation` 是什么意思?
- python - 根据火花数据框中的列值计算累积和和平均值