[英]Nodejs server: Failed to load resource: the server responded with a status of 404 (Not Found)
[英]Failed to load resource: the server responded with a status of 404 (Not Found) while my backend accepts the request
是否可以在 express 上使用 2 个补丁? 因为我的路线有问题。 我的添加产品完美运行。 但另一个是在客户端给我 404 状态。 我试图安慰我的 req.body 并且数据被接受了。我有点困惑这里有什么问题。
这是我的服务器端路由。
router.patch('/admin/collections/all/:id', addOwnerProducts);
router.patch('/admin/collections/view/:id', updateOwnerProduct);
我不确定问题是在客户端还是服务器端。 我目前正在为我的请求使用 axios,这是我的更新产品的 axios。
export const editItem = (admin,productname,price,quantity,categoryfilter,description,timestamp) => api.patch(`/admin/collections/view/${admin}`,
{
store: [
{
productname: productname,
price: price,
quantity: quantity,
categoryfilter: categoryfilter,
description: description,
timestamp: timestamp
}
]
}
)
这是请求后客户端的错误。
您可以在路由器中使用相同的 HTTP 动词有多个端点。 它只会匹配第一个适用的路线。 不知道发生了什么。 让我们做一个琐碎的拳头:
app.use(router)
确保正在查找这些patch
路由。res.sendStatus(404)
希望这能提供一个见解
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.