javascript - javascript: JSON.Stringify 不显示整个对象
问题描述
我有一个 axios 请求,并且 catch 中的 err 对象看起来像这样
但是当我尝试使用检查错误对象时
console.log(JSON.stringify(err, null, 2));
我只看到
{
"message": "Request failed with status code 400",
"name": "Error",
"stack": "Error: Request failed with status code 400\n at createError (http://localhost:3000/material-dashboard-react/static/js/vendors~main.chunk.js:43013:15)\n at settle (http://localhost:3000/material-dashboard-react/static/js/vendors~main.chunk.js:43247:12)\n at XMLHttpRequest.handleLoad (http://localhost:3000/material-dashboard-react/static/js/vendors~main.chunk.js:42487:7)",
"config": {
"url": "dj-rest-auth/login/",
"method": "post",
"data": "{\"email\":\"admin@test.com\",\"password\":\"admin\"}",
"headers": {
"Accept": "application/json",
"Content-Type": "application/json"
},
"baseURL": "http://localhost:8025",
"transformRequest": [
null
],
"transformResponse": [
null
],
"timeout": 0,
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
"maxContentLength": -1,
"maxBodyLength": -1
}
}
我没有看到 err 对象内的响应对象
如何使JSON.stringify
显示整个对象
解决方案
不要JSON.stringify()
错误对象。而只是console.log(err)
推荐阅读
- python - 将两个不同形状的numpy数组相乘时是否有自动广播的功能?
- swift - 以编程方式向左或向右移动空间 OSX
- python - 我有一个 Excel 表,其中包含一些页眉和页脚以及数据,现在我想在其间编辑该数据框的一列
- python - 如何用python在一个系列中逐月交换?
- hive - 从 Hive 表中检索 JSON 原始文件数据
- python - matplotlib 添加到 tkinter 中的 panedwindow
- cakephp - 在 CakePHP 3 中调用布尔错误时的成员函数 build()
- sql-server - SQL Server 将列中的所有数字加 1
- python - UnicodeEncodeError:“charmap”编解码器无法在位置 4297 编码字符“\u221e”:字符映射到
- java - 在 Java 中使用 Streams 和过滤器并与可变参数匹配