[英]Why am I getting Cannot read property 'getCenter' of undefined when trying to access my embed google map?
[英]why I am getting undefined when I try to access on my property in node js
当我控制收到的请求类型时,我已经将数据从前端发送到后端,我可以看到数据显示在控制台中,但是当我尝试访问这些属性时,我得到了未定义的属性。 我也尝试过查询,正文,但当我尝试访问该属性时,两者都未定义。
后端代码:
// DELETE SHORT URL
app.delete('/delete/:shortUrl', async (res, req) => {
console.log(req);
console.log(req.params, 'req.params');
})
前端:
// DELETE
const deleteUrl = (id) => {
fetch(`http://localhost:5000/delete/${id}`, {
method: 'DELETE'
}).then(res => res.json())
.then(data => {
console.log(data);
if (data.deletedCount) {
alert('Order Deleted')
// const remainingOrders = orders.filter(order => order._id !== id)
// setOrders(remainingOrders)
}
})
.finally(() => setLoadings(false))
}
根据 Express文档,路由回调的参数 (req & res) 是相反的,所以你应该:
app.delete('/delete/:shortUrl', (req, res) => {
console.log(req);
console.log(req.params, 'req.params');
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.