javascript - jquery ajaxComplete 在 axios 中的等价物
问题描述
开始学习 axios,我很喜欢它!
快速的问题,找不到答案,也许没有。
在 jQuery ajax 中有一个名为 ajaxComplete 的方法,我在徘徊,如果在 axios 中有一个等价物?
解决方案
axios 使用承诺。您可以使用
axios.get(url,[options]).then(res=>{
/* hande it here */
})
如果您没有基本知识,请查看 js 承诺如何工作https://web.dev/promises/
对于全局处理 axios 事件,这可能会有所帮助https://auralinna.blog/post/2019/global-http-request-and-response-handling-with-the-axios-interceptor/
推荐阅读
- python - 如何在python3中请求之前查看输入提示
- typescript - 如何将strapi、graphql和postgres连接在一起?
- c - 扫描文件会将功能发送到无响应模式?
- angular - Angular:Karma 给出错误错误:NullInjectorError:没有提供 ElementRef!从 v7 升级到 v8 后
- node.js - 如何在建立连接时使用 knex npm 包获取 MySQL connectionId?
- aws-sdk-js - @aws-sdk/client-s3 getObject 不获取最新版本的版本化存储桶对象
- android - Flutter 项目中使用 Cocos 引擎作为模块
- c# - C# 使用反射将特定属性序列化为 JSON?
- github - GitHub api code_frequency 所有的返回值是什么
- iis - Blazor webassembly (net5.0) 发布在 IIS 中不起作用