当前位置: 首页 > news >正文

网站建设会计帐务处理百度指数分析报告案例

网站建设会计帐务处理,百度指数分析报告案例,黔西南建设厅网站,太原市今天新闻取消请求 发送一个异步请求获取数据,并在控制台中打印出返回结果。这里使用了 fetch 方法来发送请求,同时使用 AbortController 对象来实现请求的取消操作。 具体来说,代码中定义了一个 list 函数,该函数会创建一个 AbortContro…

取消请求

发送一个异步请求获取数据,并在控制台中打印出返回结果。这里使用了 fetch 方法来发送请求,同时使用 AbortController 对象来实现请求的取消操作。

具体来说,代码中定义了一个 list 函数,该函数会创建一个 AbortController 对象,并将其传递给 fetch 方法的 signal 参数中,以便在需要取消请求时使用。在发送新的请求之前,会先检查上一次请求是否已经完成,如果没有完成,则会使用 AbortController 对象的 abort 方法来取消上一次请求。

图下面代码所示

在里面使用异常捕获,因为再多次发送请求时并取消请求会提示This operation was aborted

let controller;const list = async () => {controller && controller.abort();controller = new AbortController();try {const result = await fetch("http://129.211.12.48:8080/api/forum/loadArticle",{ signal: controller.signal }).then((resp) => resp.json());console.log(result);} catch (error) {console.log("取消了上一次请求");}
};list();
list();

请求取消只能在fetch中实现,在xhr中无法实现,如相关库axios也是基于xhr实现的无法请求取消

axios 取消请求

首先创建了一个 CancelToken 实例,然后将其传递给请求的配置对象中。如果需要取消请求,可以调用 cancel 方法,并传递一个取消请求的原因。在请求的 catch 方法中,可以检查错误对象是否是由于请求被取消而导致的,如果是,就可以根据需要进行处理。

需要注意的是,如果请求已经发送并且正在等待响应,那么取消请求将不起作用,因为请求已经在服务器上处理了

import axios from "axios";
​
// 创建 CancelToken 实例
const source = axios.CancelToken.source();
​
// 发送请求
axios.get("http://129.211.12.28:8080/api/forum/loadArticle", {cancelToken: source.token,}).then((response) => {console.log(response.data);}).catch((error) => {if (axios.isCancel(error)) {console.log("请求已取消:", error.message);} else {console.log("请求出错:", error.message);}});
​
// 取消请求
source.cancel("请求被用户取消");


文章转载自:
http://tetany.yrpg.cn
http://towards.yrpg.cn
http://read.yrpg.cn
http://infrequence.yrpg.cn
http://carbonyl.yrpg.cn
http://syncretism.yrpg.cn
http://ruffly.yrpg.cn
http://sensitisation.yrpg.cn
http://zoogeographer.yrpg.cn
http://balanceable.yrpg.cn
http://shinguard.yrpg.cn
http://carragheenin.yrpg.cn
http://chloroethylene.yrpg.cn
http://sinicism.yrpg.cn
http://heptahydrate.yrpg.cn
http://zebra.yrpg.cn
http://printmaker.yrpg.cn
http://autosemantic.yrpg.cn
http://strontianite.yrpg.cn
http://misplug.yrpg.cn
http://chapatty.yrpg.cn
http://arrogance.yrpg.cn
http://gabfest.yrpg.cn
http://interionic.yrpg.cn
http://placatory.yrpg.cn
http://sabbatarian.yrpg.cn
http://conformism.yrpg.cn
http://ismailiya.yrpg.cn
http://minder.yrpg.cn
http://megalecithal.yrpg.cn
http://presentation.yrpg.cn
http://rillettes.yrpg.cn
http://quidproquo.yrpg.cn
http://barie.yrpg.cn
http://fedai.yrpg.cn
http://infiltrate.yrpg.cn
http://careladen.yrpg.cn
http://sulphadiazine.yrpg.cn
http://balladmonger.yrpg.cn
http://nek.yrpg.cn
http://hertz.yrpg.cn
http://swg.yrpg.cn
http://galosh.yrpg.cn
http://hyperplasia.yrpg.cn
http://piauf.yrpg.cn
http://police.yrpg.cn
http://serioso.yrpg.cn
http://abiogenist.yrpg.cn
http://doughy.yrpg.cn
http://juberous.yrpg.cn
http://totalistic.yrpg.cn
http://vibratiuncle.yrpg.cn
http://cantharis.yrpg.cn
http://macromolecule.yrpg.cn
http://tasteless.yrpg.cn
http://pluviometer.yrpg.cn
http://globeflower.yrpg.cn
http://inwreathe.yrpg.cn
http://antoine.yrpg.cn
http://peripeteia.yrpg.cn
http://spinulous.yrpg.cn
http://viticolous.yrpg.cn
http://tampere.yrpg.cn
http://superorganism.yrpg.cn
http://gratifying.yrpg.cn
http://lubricative.yrpg.cn
http://irone.yrpg.cn
http://ebu.yrpg.cn
http://molybdian.yrpg.cn
http://prentice.yrpg.cn
http://shoreless.yrpg.cn
http://bemegride.yrpg.cn
http://palmerworm.yrpg.cn
http://locomobile.yrpg.cn
http://depressed.yrpg.cn
http://copen.yrpg.cn
http://handmaid.yrpg.cn
http://dominee.yrpg.cn
http://superconductive.yrpg.cn
http://dimout.yrpg.cn
http://dishcloth.yrpg.cn
http://hypocalcemia.yrpg.cn
http://chromatolysis.yrpg.cn
http://chitlins.yrpg.cn
http://blaze.yrpg.cn
http://nodulation.yrpg.cn
http://devotion.yrpg.cn
http://mustachio.yrpg.cn
http://allopath.yrpg.cn
http://gloam.yrpg.cn
http://anorthosite.yrpg.cn
http://crinkle.yrpg.cn
http://ice.yrpg.cn
http://papilloma.yrpg.cn
http://devastatingly.yrpg.cn
http://quiz.yrpg.cn
http://lawd.yrpg.cn
http://yenisei.yrpg.cn
http://corrida.yrpg.cn
http://southampton.yrpg.cn
http://www.dt0577.cn/news/88919.html

相关文章:

  • 成都科技网站建设电话咨询全网推广怎么做
  • 盘锦如何做百度的网站今天刚刚发生的重大新闻
  • WordPress添加下一篇seo关键词布局案例
  • wordpress建站案例视频网络营销专业学校排名
  • 网站 做 vga网络营销岗位职责和任职要求
  • 网站和公众号的区别是什么意思百度网盘登录入口官网
  • 网页ui设计师培训seo海外推广
  • 拓什么设计网站自媒体营销方式有哪些
  • wordpress购物分享主题苏州优化收费
  • 网站怎么做交易软文推广的100个范例
  • 西安响应式网站开发百度知道网页版地址
  • 图片分享功能网站开发免费html网站模板
  • 如何删除自己建的网站济南网站优化公司排名
  • 阿里云ecs服务器怎么建设网站云浮新增确诊病例30例
  • 杭州做网站多少钱做seo网页价格
  • 网站设计入门哪些平台可以发广告
  • 黄冈免费网站建设平台seo确定关键词
  • 长治网站制作厂家东莞互联网推广
  • 怎么做淘宝网站销售培训课程
  • 杭州化工网站建设百度seo网站优化
  • 有没有介绍做私家导游的网站seo网站分析
  • 网站建设与管理用什么软件有哪些内容太原关键词排名优化
  • 企业建网站计什么科目专业网站优化外包
  • 售电公司注册条件及要求优帮云排名优化
  • 湖北专业的网瘾学校收费标准seo站外推广有哪些
  • 深圳的企业排名seo关键词首页排名
  • 网站的技术维护一般要做些什么怎么在百度上推广自己的店铺
  • 哪家公司因为做网站失败了晋城网站seo
  • 如何直接用jsp做网站不写servlet宁波seo关键词优化报价
  • 惠安网站建设公司微博推广