<legend id='0611s'><style id='0611s'><dir id='0611s'><q id='0611s'></q></dir></style></legend>
      <bdo id='0611s'></bdo><ul id='0611s'></ul>
    <tfoot id='0611s'></tfoot>

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

      2. fetch 函数返回 Promise &lt;pending&gt;

        fetch function return Promise lt;pendinggt;(fetch 函数返回 Promise lt;pendinggt;)
          <bdo id='qKRyl'></bdo><ul id='qKRyl'></ul>
          1. <tfoot id='qKRyl'></tfoot>

            <legend id='qKRyl'><style id='qKRyl'><dir id='qKRyl'><q id='qKRyl'></q></dir></style></legend>

              • <small id='qKRyl'></small><noframes id='qKRyl'>

                    <tbody id='qKRyl'></tbody>

                  <i id='qKRyl'><tr id='qKRyl'><dt id='qKRyl'><q id='qKRyl'><span id='qKRyl'><b id='qKRyl'><form id='qKRyl'><ins id='qKRyl'></ins><ul id='qKRyl'></ul><sub id='qKRyl'></sub></form><legend id='qKRyl'></legend><bdo id='qKRyl'><pre id='qKRyl'><center id='qKRyl'></center></pre></bdo></b><th id='qKRyl'></th></span></q></dt></tr></i><div id='qKRyl'><tfoot id='qKRyl'></tfoot><dl id='qKRyl'><fieldset id='qKRyl'></fieldset></dl></div>
                  本文介绍了fetch 函数返回 Promise &lt;pending&gt;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  所以我的代码在这里返回一个 Promise,因为我使用的是 then 语法,所以我不知道为什么会这样:-??

                  So my code here return a Promise and since I'm using then syntax I don't know why that happens :-??

                  fetch('someurltoAJsonFile.json')
                    .then(function(response) {
                      console.log(response.json());});
                  

                  推荐答案

                  node-fetch 库中的response.json() 也返回一个promise,改为尝试

                  response.json() in node-fetch library also returns a promise, instead try

                  fetch('someurltoAJsonFile.json')
                    .then(response => response.json())
                    .then(data => {
                      console.log(data)
                    });
                  

                  您可以在这里

                  返回的响应似乎不在有效的 json 中,所以为了完整起见,这里是文本代码

                  It seems that the returned response wasn't in the valid json, so for the sake of completeness here is a code for text

                  fetch('someurltoAJsonFile.json')
                    .then(response => response.text())
                    .then(data => {
                      console.log(data)
                    });
                  

                  这篇关于fetch 函数返回 Promise &lt;pending&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Fetch multiple links inside foreach loop(在 foreach 循环中获取多个链接)
                  Backbone Fetch Request is OPTIONS method(Backbone Fetch Request 是 OPTIONS 方法)
                  Fetch API leaks memory in Chrome(Fetch API 在 Chrome 中泄漏内存)
                  How can I download and save a file using the Fetch API? (Node.js)(如何使用 Fetch API 下载和保存文件?(Node.js))
                  Send blob data to node using fetch, multer, express(使用 fetch、multer、express 将 blob 数据发送到节点)
                  Sending a custom User-Agent string along with my headers (fetch)(发送自定义用户代理字符串以及我的标头(获取))

                  1. <tfoot id='WobHe'></tfoot>

                    <legend id='WobHe'><style id='WobHe'><dir id='WobHe'><q id='WobHe'></q></dir></style></legend>

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

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

                          <tbody id='WobHe'></tbody>
                          • <bdo id='WobHe'></bdo><ul id='WobHe'></ul>