<small id='1Gvoj'></small><noframes id='1Gvoj'>

      <bdo id='1Gvoj'></bdo><ul id='1Gvoj'></ul>

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

      从 fetch 请求中获取 html

      Getting html from fetch request(从 fetch 请求中获取 html)
          <bdo id='YoQ4a'></bdo><ul id='YoQ4a'></ul>
            <tbody id='YoQ4a'></tbody>
              • <i id='YoQ4a'><tr id='YoQ4a'><dt id='YoQ4a'><q id='YoQ4a'><span id='YoQ4a'><b id='YoQ4a'><form id='YoQ4a'><ins id='YoQ4a'></ins><ul id='YoQ4a'></ul><sub id='YoQ4a'></sub></form><legend id='YoQ4a'></legend><bdo id='YoQ4a'><pre id='YoQ4a'><center id='YoQ4a'></center></pre></bdo></b><th id='YoQ4a'></th></span></q></dt></tr></i><div id='YoQ4a'><tfoot id='YoQ4a'></tfoot><dl id='YoQ4a'><fieldset id='YoQ4a'></fieldset></dl></div>
              • <small id='YoQ4a'></small><noframes id='YoQ4a'>

                <tfoot id='YoQ4a'></tfoot><legend id='YoQ4a'><style id='YoQ4a'><dir id='YoQ4a'><q id='YoQ4a'></q></dir></style></legend>

              • 本文介绍了从 fetch 请求中获取 html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试从 api 响应中获取 html.如果我执行以下获取请求:

                I am trying to get the html from an api response. If I execute the following fetch request:

                const fetchHtml = () => {
                  return fetch('local:8080/api/getHtml')
                    .then((response) => {
                      console.log("Response:");
                      console.log(response.text());
                    })
                    .then((data) => {
                      console.log("Data:");
                      console.log(data);
                    });
                  };
                };
                

                我收到以下控制台消息:

                I get the following console message:

                Response:
                Promise{<pending>}
                  __proto__: Promise
                  [[PromiseStatus]]: "resolved"
                  [[PromiseValue]]: "<html><head><title>Your interest in PROGRAM_NAME</ `Show 108 096 more Copy`"
                Data:
                undefined
                

                如何从我的 fetch api 请求中获取返回的 html 承诺值?谢谢.

                How do I get the returned html promise value from my fetch api request? Thanks.

                推荐答案

                你必须从.then返回response.text

                you have to return response.text from .then

                const fetchHtml = () => {
                  return fetch('local:8080/api/getHtml')
                    .then((response) => {
                      return response.text();
                    }).then((text) => {
                      console.log(text);
                    });
                  };
                };

                这篇关于从 fetch 请求中获取 html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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)(发送自定义用户代理字符串以及我的标头(获取))

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

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

                        <tfoot id='pOsnb'></tfoot>