• <bdo id='TndBG'></bdo><ul id='TndBG'></ul>
    1. <i id='TndBG'><tr id='TndBG'><dt id='TndBG'><q id='TndBG'><span id='TndBG'><b id='TndBG'><form id='TndBG'><ins id='TndBG'></ins><ul id='TndBG'></ul><sub id='TndBG'></sub></form><legend id='TndBG'></legend><bdo id='TndBG'><pre id='TndBG'><center id='TndBG'></center></pre></bdo></b><th id='TndBG'></th></span></q></dt></tr></i><div id='TndBG'><tfoot id='TndBG'></tfoot><dl id='TndBG'><fieldset id='TndBG'></fieldset></dl></div>

      <tfoot id='TndBG'></tfoot>

    2. <legend id='TndBG'><style id='TndBG'><dir id='TndBG'><q id='TndBG'></q></dir></style></legend>

      <small id='TndBG'></small><noframes id='TndBG'>

      使用 json-server 正确获取删除调用?

      Proper Fetch call for Delete using json-server?(使用 json-server 正确获取删除调用?)

        <tfoot id='4uqvF'></tfoot>

            <tbody id='4uqvF'></tbody>
        1. <i id='4uqvF'><tr id='4uqvF'><dt id='4uqvF'><q id='4uqvF'><span id='4uqvF'><b id='4uqvF'><form id='4uqvF'><ins id='4uqvF'></ins><ul id='4uqvF'></ul><sub id='4uqvF'></sub></form><legend id='4uqvF'></legend><bdo id='4uqvF'><pre id='4uqvF'><center id='4uqvF'></center></pre></bdo></b><th id='4uqvF'></th></span></q></dt></tr></i><div id='4uqvF'><tfoot id='4uqvF'></tfoot><dl id='4uqvF'><fieldset id='4uqvF'></fieldset></dl></div>
          <legend id='4uqvF'><style id='4uqvF'><dir id='4uqvF'><q id='4uqvF'></q></dir></style></legend>

              <small id='4uqvF'></small><noframes id='4uqvF'>

              • <bdo id='4uqvF'></bdo><ul id='4uqvF'></ul>

                本文介绍了使用 json-server 正确获取删除调用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用 json-server 创建一个假服务器并从中获取内容.GET 可以正常工作,当我添加到 JSON 时 POST 也可以正常工作,但是当我删除任何内容时出现 404 错误.形成的 url 似乎是正确的,它确实指向我要删除的 JSON,但它仍然给我一个 404.有什么想法吗?

                Im using json-server to create a fake server and Im fetching stuff from it. The GET works correctly, so does the POST when I add to the JSON, however I get a 404 error when i DELETE anything. The formed url seems to be correct, and it does point to the very JSON I want to delete, however it still gives me a 404. Any ideas?

                deleteService = () => {
                    return fetch(
                      `http://${delete_url}/services?id=${this.props.data.id}&domain=${
                        this.props.data.domain
                      }`,
                      {
                        method: "DELETE"
                      }
                    )
                      .then(res => res.json());
                  };
                

                我的 JSON 示例

                {
                  "services": [
                    {
                      "id": "1",
                      "domain": "Domain1",
                      "service_name": "Get Users",
                      "service_version": "1.0.0",
                      "method": "GET",
                      "path": "/abc/def",
                      "protocol": "HTTP/1.1",
                      "host": "test.com",
                      "response": "200"
                    }
                }
                

                错误

                删除 http://localhost:3100/services?id=1&domain=Domain1 404(不是找到)

                DELETE http://localhost:3100/services?id=1&domain=Domain1 404 (Not Found)

                即使 URL 正确存在于我的 JSON 中..

                Even though the URL correctly exists on my JSON..

                推荐答案

                尝试使用 axios

                 await axios.delete(`http://localhost:3100/servicess/${this.props.data.id}`) 
                

                并在函数中将 id 作为参数传递

                and in the function pass the id as a param

                这篇关于使用 json-server 正确获取删除调用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                业务场景:使用update语句去更新数据库字段。 原因:update接收值不正确。原来代码: $query = "UPDATE student SET date = now() WHERE id = $id";$result = $mysqli-query($query2) or die($mysqli-error); // 问题出现了在这句 $data = $result-fetch_ass
                在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)

                        <tbody id='SByc6'></tbody>
                      <legend id='SByc6'><style id='SByc6'><dir id='SByc6'><q id='SByc6'></q></dir></style></legend>
                      <i id='SByc6'><tr id='SByc6'><dt id='SByc6'><q id='SByc6'><span id='SByc6'><b id='SByc6'><form id='SByc6'><ins id='SByc6'></ins><ul id='SByc6'></ul><sub id='SByc6'></sub></form><legend id='SByc6'></legend><bdo id='SByc6'><pre id='SByc6'><center id='SByc6'></center></pre></bdo></b><th id='SByc6'></th></span></q></dt></tr></i><div id='SByc6'><tfoot id='SByc6'></tfoot><dl id='SByc6'><fieldset id='SByc6'></fieldset></dl></div>

                        <tfoot id='SByc6'></tfoot>

                        <small id='SByc6'></small><noframes id='SByc6'>

                          <bdo id='SByc6'></bdo><ul id='SByc6'></ul>