pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

  • <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="3jhjlnp" 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="35tfrpf" 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="55xrjzx" 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>
                            主站蜘蛛池模板: 网带通过式抛丸机,,网带式打砂机,吊钩式,抛丸机,中山抛丸机生产厂家,江门抛丸机,佛山吊钩式,东莞抛丸机,中山市泰达自动化设备有限公司 | 济南律师,济南法律咨询,山东法律顾问-山东沃德律师事务所 | PC构件-PC预制构件-构件设计-建筑预制构件-PC构件厂-锦萧新材料科技(浙江)股份有限公司 | 济南货架定做_仓储货架生产厂_重型货架厂_仓库货架批发_济南启力仓储设备有限公司 | 热熔胶网膜|pes热熔网膜价格|eva热熔胶膜|热熔胶膜|tpu热熔胶膜厂家-苏州惠洋胶粘制品有限公司 | 石膏基自流平砂浆厂家-高强石膏基保温隔声自流平-轻质抹灰石膏粉砂浆批发-永康市汇利建设有限公司 | 铸铝门厂家,别墅大门庭院大门,别墅铸铝门铜门[十大品牌厂家]军强门业 | 山东螺杆空压机,烟台空压机,烟台开山空压机-烟台开山机电设备有限公司 | 桁架机器人_桁架机械手_上下料机械手_数控车床机械手-苏州清智科技装备制造有限公司 | 北京网络营销推广_百度SEO搜索引擎优化公司_网站排名优化_谷歌SEO - 北京卓立海创信息技术有限公司 | 聚氨酯保温钢管_聚氨酯直埋保温管道_聚氨酯发泡保温管厂家-沧州万荣防腐保温管道有限公司 | 天津仓储物流-天津电商云仓-天津云仓一件代发-博程云仓官网 | 防火卷帘门价格-聊城一维工贸特级防火卷帘门厂家▲ | 浙江筋膜枪-按摩仪厂家-制造商-肩颈按摩仪哪家好-温州市合喜电子科技有限公司 | 变位机,焊接变位机,焊接变位器,小型变位机,小型焊接变位机-济南上弘机电设备有限公司 | 中空玻璃生产线,玻璃加工设备,全自动封胶线,铝条折弯机,双组份打胶机,丁基胶/卧式/立式全自动涂布机,玻璃设备-山东昌盛数控设备有限公司 | 真空上料机(一种真空输送机)-百科 | 综合管廊模具_生态,阶梯护坡模具_检查井模具制造-致宏模具厂家 | 外贮压-柜式-悬挂式-七氟丙烷-灭火器-灭火系统-药剂-价格-厂家-IG541-混合气体-贮压-非贮压-超细干粉-自动-灭火装置-气体灭火设备-探火管灭火厂家-东莞汇建消防科技有限公司 | 期货软件-专业期货分析软件下载-云智赢 | BAUER减速机|ROSSI-MERSEN熔断器-APTECH调压阀-上海爱泽工业设备有限公司 | 精密模具加工制造 - 富东懿 | 新疆系统集成_新疆系统集成公司_系统集成项目-新疆利成科技 | 鄂泉泵业官网|(杭州、上海、全国畅销)大流量防汛排涝泵-LW立式排污泵 | 庭院灯_太阳能景观灯_草坪灯厂家_仿古壁灯-重庆恒投科技 | 金属检测机_金属分离器_检针验针机_食品药品金属检探测仪器-广东善安科技 | 厦门ISO认证|厦门ISO9001认证|厦门ISO14001认证|厦门ISO45001认证-艾索咨询专注ISO认证行业 | 物联网卡_物联网卡购买平台_移动物联网卡办理_移动联通电信流量卡通信模组采购平台? | 章丘丰源机械有限公司 - 三叶罗茨风机,罗茨鼓风机,罗茨风机 | 健身器材-健身器材厂家专卖-上海七诚健身器材有限公司 | 酸度计_PH计_特斯拉计-西安云仪| 温州中研白癜风专科_温州治疗白癜风_温州治疗白癜风医院哪家好_温州哪里治疗白癜风 | 电杆荷载挠度测试仪-电杆荷载位移-管桩测试仪-北京绿野创能机电设备有限公司 | 【官网】博莱特空压机,永磁变频空压机,螺杆空压机-欧能优 | 凝胶成像仪,化学发光凝胶成像系统,凝胶成像分析系统-上海培清科技有限公司 | 知企服务-企业综合服务(ZiKeys.com)-品优低价、种类齐全、过程管理透明、速度快捷高效、放心服务,知企专家! | 中矗模型-深圳中矗模型设计有限公司 | 彩超机-黑白B超机-便携兽用B超机-多普勒彩超机价格「大为彩超」厂家 | 老城街小面官网_正宗重庆小面加盟技术培训_特色面馆加盟|牛肉拉面|招商加盟代理费用多少钱 | 塑料薄膜_PP薄膜_聚乙烯薄膜-常州市鑫美新材料包装厂 | 东莞精密模具加工,精密连接器模具零件,自動機零件,冶工具加工-益久精密 |