久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

        在 JavaScript 中攔截 fetch() API 請求和響應

        Intercept fetch() API requests and responses in JavaScript(在 JavaScript 中攔截 fetch() API 請求和響應)
      2. <small id='NpFKm'></small><noframes id='NpFKm'>

      3. <i id='NpFKm'><tr id='NpFKm'><dt id='NpFKm'><q id='NpFKm'><span id='NpFKm'><b id='NpFKm'><form id='NpFKm'><ins id='NpFKm'></ins><ul id='NpFKm'></ul><sub id='NpFKm'></sub></form><legend id='NpFKm'></legend><bdo id='NpFKm'><pre id='NpFKm'><center id='NpFKm'></center></pre></bdo></b><th id='NpFKm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NpFKm'><tfoot id='NpFKm'></tfoot><dl id='NpFKm'><fieldset id='NpFKm'></fieldset></dl></div>

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

              <bdo id='NpFKm'></bdo><ul id='NpFKm'></ul>
                <tbody id='NpFKm'></tbody>
                <tfoot id='NpFKm'></tfoot>

                  本文介紹了在 JavaScript 中攔截 fetch() API 請求和響應的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想在 JavaScript 中攔截 fetch API 請求和響應.

                  I want to intercept fetch API requests and responses in JavaScript.

                  例如,在發送請求之前我要截取請求的 URL.我也想在響應到達后攔截它.

                  For example, before sending the request I want to intercept the request URL. I'd like to intercept the response once it arrives as well.

                  以下代碼用于攔截所有XMLHTTPRequest的響應.

                  The below code is for intercepting responses of all XMLHTTPRequests.

                  (function(open) {
                    XMLHttpRequest.prototype.open = function(XMLHttpRequest) {
                      var self = this;
                      this.addEventListener("readystatechange", function() {
                        if (this.responseText.length > 0 && 
                            this.readyState == 4 && 
                            this.responseURL.indexOf('www.google.com') >= 0) {
                  
                          Object.defineProperty(self, 'response', {
                            get: function() { return bValue; },
                            set: function(newValue) { bValue = newValue; },
                            enumerable: true,
                            configurable: true
                          });
                          self.response = 'updated value' // Intercepted Value 
                        }
                      }, false);
                      open.apply(this, arguments);
                    };
                  })(XMLHttpRequest.prototype.open);
                  

                  我想為 fetch() API 實現相同的功能.我該怎么做?

                  I want to implement the same feature for fetch() API. How can I do this?

                  推薦答案

                  為了攔截獲取請求和參數,我們可以采用下面提到的方式.它解決了我的問題.

                  For intercepting the fetch request and parameter we can go for below mentioned way. its resolved my issue.

                   const constantMock = window.fetch;
                   window.fetch = function() {
                       // Get the parameter in arguments
                       // Intercept the parameter here 
                      return constantMock.apply(this, arguments)
                   }
                  

                  這篇關于在 JavaScript 中攔截 fetch() API 請求和響應的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)

                            <tbody id='Rhe1a'></tbody>
                        • <i id='Rhe1a'><tr id='Rhe1a'><dt id='Rhe1a'><q id='Rhe1a'><span id='Rhe1a'><b id='Rhe1a'><form id='Rhe1a'><ins id='Rhe1a'></ins><ul id='Rhe1a'></ul><sub id='Rhe1a'></sub></form><legend id='Rhe1a'></legend><bdo id='Rhe1a'><pre id='Rhe1a'><center id='Rhe1a'></center></pre></bdo></b><th id='Rhe1a'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Rhe1a'><tfoot id='Rhe1a'></tfoot><dl id='Rhe1a'><fieldset id='Rhe1a'></fieldset></dl></div>

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

                        • <tfoot id='Rhe1a'></tfoot>
                            <bdo id='Rhe1a'></bdo><ul id='Rhe1a'></ul>
                            <legend id='Rhe1a'><style id='Rhe1a'><dir id='Rhe1a'><q id='Rhe1a'></q></dir></style></legend>
                            主站蜘蛛池模板: 午夜视频在线 | 国产一级片在线播放 | 国产精品九九九 | 亚洲一区二区日韩 | 天天干国产 | 超碰av免费| 成人无遮挡毛片免费看 | 一级大片网站 | 亚洲毛片在线 | 在线视频一区二区 | 看a网站 | 欧美专区在线观看 | 欧美成ee人免费视频 | 成人夜晚看av | 亚洲国产精品视频 | 黄在线免费观看 | 午夜精品久久久久久久久久久久久 | 雨宫琴音一区二区在线 | 日韩午夜电影在线观看 | 亚洲精品乱码久久久久久蜜桃91 | 狠狠亚洲 | 一区二区在线观看av | 国产日产精品一区二区三区四区 | 一区二区国产精品 | 国产专区视频 | 中文字幕亚洲一区二区三区 | 国产精品久久国产精品 | 国产91丝袜 | 99久久婷婷国产亚洲终合精品 | 久久成人免费观看 | 一二三四在线视频观看社区 | 精品国产乱码久久久久久88av | 久久久91精品国产一区二区三区 | 自拍视频一区二区三区 | 一区二区三区四区不卡 | 国产一级在线观看 | 欧美日韩精品久久久免费观看 | 97精品超碰一区二区三区 | 男女免费观看在线爽爽爽视频 | 美女黄视频网站 | 国产成人久久久 |