【发布时间】:2020-09-26 02:41:47
【问题描述】:
我正在尝试使用 Axios 从后端发出请求,这是请求的数据
[
{
"_id": "5ed99cd7972ceb1e203ff3d4",
"model": "76 Runer Nylonmedieval Blue-grey Violet ",
"code": "352077-14",
"brand": "PUMA",
"description": "Corres mucho",
"value": 119000,
"size": 11,
"stock": 50,
"date": "2020-06-05T01:14:17.000Z",
"image": "upload\\352077-14.jpg",
"total": 714000
},
{
"_id": "5edc01f0efed972e1c13c76e",
"model": "Force",
"code": "200-1142",
"brand": "Reebok",
"description": "Perfectos para realizar crossfit, con dos agarres laterales perfectos para Rope Climbing",
"value": 310000,
"size": 45,
"stock": 20,
"date": "2020-06-06T20:50:44.000Z",
"image": "upload\\Screenshot_8.png",
"total": 1240000
},
{
"_id": "5edc0163efed972e1c13c76c",
"model": "Elegant",
"code": "2002-1",
"brand": "Velez",
"description": "comodos y perfectos para ocasiones especiales ",
"value": 340000,
"size": 41,
"stock": 13,
"date": "2020-06-06T20:48:26.000Z",
"image": "upload\\Screenshot_1.png",
"total": 680000
}
]
但是当我尝试在我的页面中 console.log 时,我只是得到响应“数据 [object Object],[object Object],[object Object]”,所以我不能使用任何 json 数据。这是前端的axios请求:
axios.get('http://localhost:5000/users/carProducts/'+ID.userid)
.then(res =>{
console.log('data '+res.data)
})
.catch(error => console.log(error));
【问题讨论】:
标签: javascript axios