当前位置:网站首页>TypeError: Cannot read properties of undefined (reading ‘cancelToken‘)
TypeError: Cannot read properties of undefined (reading ‘cancelToken‘)
2022-07-05 09:41:00 【Oliver尹】
问题:在封装axios的时候,测试阶段突然报错TypeError: Cannot read properties of undefined (reading ‘cancelToken’)
描述:最近,为了解决老的axios封装中存在的一些问题,决定对axios的封装进行改动优化一下,当改完请求拦截之后进入自测的时候,突然报错TypeError: Cannot read properties of undefined (reading ‘cancelToken’),很奇怪,因为还没有到cancelToken这一部分
解答:其实原因很简单,请求拦截器编写完成之后,没有将config返回,那么就会报这个错,着实大意了
// 报错了
this.axios.interceptors.request.use(
(config: AxiosRequestConfig) => {
requestInterceptors(config);
},
(error) => {
Promise.reject(error);
}
);
这里的请求拦截器必须改成有返回值
this.axios.interceptors.request.use(
(config: AxiosRequestConfig) => {
return requestInterceptors(config);
},
(error) => {
Promise.reject(error);
}
);
改成这种后就不再报错了
边栏推荐
- Are databases more popular as they get older?
- 卷起來,突破35歲焦慮,動畫演示CPU記錄函數調用過程
- Apache DolphinScheduler 入门(一篇就够了)
- 美图炒币半年亏了3个亿,华为被曝在俄罗斯扩招,AlphaGo的同类又刷爆一种棋,今日更多大新闻在此...
- 基于单片机步进电机控制器设计(正转反转指示灯挡位)
- TDengine × Intel edge insight software package accelerates the digital transformation of traditional industries
- The comparison of every() and some() in JS uses a power storage plan
- 宝塔面板MySQL无法启动
- 天龙八部TLBB系列 - 关于包裹掉落的物品
- cent7安装Oracle数据库报错
猜你喜欢

Comment obtenir le temps STW du GC (collecteur d'ordures)?

Tongweb set gzip

Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 -下

View Slide

La voie de l'évolution du système intelligent d'inspection et d'ordonnancement des petites procédures de Baidu

一种用于干式脑电图的高密度256通道电极帽

Application of data modeling based on wide table
![[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution](/img/f3/782246100bca3517d95869be80d9c5.png)
[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution

idea用debug调试出现com.intellij.rt.debugger.agent.CaptureAgent,导致无法进行调试

剪掉ImageNet 20%数据量,模型性能不下降!Meta斯坦福等提出新方法,用知识蒸馏给数据集瘦身...
随机推荐
How to choose the right chain management software?
[C language] the use of dynamic memory development "malloc"
Common fault analysis and Countermeasures of using MySQL in go language
The essence of persuasion is to remove obstacles
Windows uses commands to run kotlin
How to get the STW (pause) time of GC (garbage collector)?
把欧拉的创新带向世界 SUSE 要做那个引路人
What should we pay attention to when developing B2C websites?
La voie de l'évolution du système intelligent d'inspection et d'ordonnancement des petites procédures de Baidu
7 月 2 日邀你来TD Hero 线上发布会
Pagoda panel MySQL cannot be started
QT event filter simple case
ArcGIS Pro creating features
能源势动:电力行业的碳中和该如何实现?
卷起來,突破35歲焦慮,動畫演示CPU記錄函數調用過程
Three-level distribution is becoming more and more popular. How should businesses choose the appropriate three-level distribution system?
Solve liquibase – waiting for changelog lock Cause database deadlock
What should we pay attention to when entering the community e-commerce business?
解决idea调试过程中liquibase – Waiting for changelog lock….导致数据库死锁问题
百度智能小程序巡检调度方案演进之路