繁体   English   中英

使用带有提取 json 的 DELETE 方法未找到错误 404

[英]Error 404 Not found using DELETE method with fetch json

I am creating a webpage using JSON API REST, along XAMPP with apache server. 问题是,到目前为止,我一直在使用 DELETE 方法,到目前为止一切都很好。 但是现在,我真的被卡住了,因为我正在执行一个简单的 DELETE 方法,并且它一直返回“404 Not found”,显然我已经检查了几次我想要删除的资源存在于 JSON 文件中。 这是怎么回事? 它让我发疯......提前非常感谢你。

这是我的 JavaScript 代码

fetch(`http://localhost:3000/votes?photoId=${id}&userId=${userId}`, {
        method: "DELETE",
        headers: {
            'Authorization': 'Bearer' + getToken(),

        }
    });

而这个,我的 JSON 文件,我要删除的资源是:

"votes": [
{
  "photoId": "4",
  "userId": "6",
  "id": 2
},
{
  "photoId": "2",
  "userId": "7",
  "id": 4
},
{
  "photoId": "5",
  "userId": "9",
  "id": 5
},
{
  "photoId": "3",
  "userId": "9",
  "id": 6
},
{
  "photoId": "3",
  "userId": "6",
  "id": 7
},
{
  "photoId": "1",
  "userId": "6",
  "id": 8
},
{
  "photoId": "2",
  "userId": "6",
  "id": 12
},
{
  "photoId": "3",
  "userId": "7",
  "id": 14
},
{
  "photoId": "1",
  "userId": "7",
  "id": 15
},
{
  "photoId": "5",
  "userId": "7",
  "id": 16
},
{
  "photoId": "3",
  "userId": "11",
  "id": 17
},
{
  "photoId": "1",
  "userId": "11",
  "id": 18
},
{
  "photoId": "4",
  "userId": "9",
  "id": 19
},
{
  "photoId": "2",
  "userId": "9",
  "id": 20
},
{
  "photoId": "1",
  "userId": "9",
  "id": 21
},
{
  "photoId": "6",
  "userId": "9",
  "id": 22
},
{
  "photoId": "6",
  "userId": "6",
  "id": 23
}

],

顺便说一句,提取发生在异步 function 中,但无论如何,我认为这并不重要,我知道这很有效,因为我已经对代码进行了很多测试。 它的这个 fetch DELETE 调用是什么让我害怕.. 谢谢。

你在哪里归档 json。 给我root完成或尝试直接使用导航器访问文件。

可能您的文件不正确,根目录或文件已删除

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM