当前位置:网站首页>TypeError: Cannot read properties of undefined (reading ‘cancelToken‘)
TypeError: Cannot read properties of undefined (reading ‘cancelToken‘)
2022-07-05 10:14:00 【Oliver Yin】
problem : In the packaging axios When , An error is suddenly reported during the test TypeError: Cannot read properties of undefined (reading ‘cancelToken’)
describe : lately , In order to solve the old axios Some problems in encapsulation , The decision is right axios Change and optimize the package of , When you enter the self-test after changing the request interception , All of a sudden, an error was reported TypeError: Cannot read properties of undefined (reading ‘cancelToken’), It's strange , Because it hasn't arrived yet cancelToken This part
answer : The reason is simple , After the request interceptor is written , No will config return , Then you will report this error , Really careless
// Wrong report
this.axios.interceptors.request.use(
(config: AxiosRequestConfig) => {
requestInterceptors(config);
},
(error) => {
Promise.reject(error);
}
);
The request interceptor here must be changed to have a return value
this.axios.interceptors.request.use(
(config: AxiosRequestConfig) => {
return requestInterceptors(config);
},
(error) => {
Promise.reject(error);
}
);
If you change it to this type, you will no longer report errors
边栏推荐
- Constrained layout flow
- QT event filter simple case
- 剪掉ImageNet 20%数据量,模型性能不下降!Meta斯坦福等提出新方法,用知识蒸馏给数据集瘦身...
- QT VT100 parser
- Tianlong Babu TLBB series - about items dropped from packages
- How to use sqlcipher tool to decrypt encrypted database under Windows system
- How Windows bat script automatically executes sqlcipher command
- La vue latérale du cycle affiche cinq demi - écrans en dessous de cinq distributions moyennes
- 【小技巧】獲取matlab中cdfplot函數的x軸,y軸的數值
- Advanced opencv:bgr pixel intensity map
猜你喜欢

The king of pirated Dall · e? 50000 images per day, crowded hugging face server, and openai ordered to change its name
![[论文阅读] KGAT: Knowledge Graph Attention Network for Recommendation](/img/fa/d2061bc7bd437f062d46a009cf32cf.png)
[论文阅读] KGAT: Knowledge Graph Attention Network for Recommendation

QT event filter simple case

Pagoda panel MySQL cannot be started

Fluent generates icon prompt logo widget

历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...

【系统设计】指标监控和告警系统

Usage differences between isempty and isblank

Unity particle special effects series - the poison spray preform is ready, and the unitypackage package is directly used - on

Kotlin compose and native nesting
随机推荐
面试:List 如何根据对象的属性去重?
Applet image height adaptation and setting text line height
驱动制造业产业升级新思路的领域知识网络,什么来头?
双容水箱液位模糊PID控制系统设计与仿真(Matlab/Simulink)
@JsonAdapter注解使用
Kotlin compose multiple item scrolling
面试:Bitmap像素内存分配在堆内存还是在native中
uniapp + uniCloud+unipay 实现微信小程序支付功能
mysql80服务不启动
官网给的这个依赖是不是应该为flink-sql-connector-mysql-cdc啊,加了依赖调
Lepton 无损压缩原理及性能分析
天龙八部TLBB系列 - 单体技能群伤
Design and Simulation of fuzzy PID control system for liquid level of double tank (matlab/simulink)
Windows uses commands to run kotlin
Tianlong Babu TLBB series - single skill group injury
【系统设计】指标监控和告警系统
ByteDance Interviewer: how to calculate the memory size occupied by a picture
Interview: how does the list duplicate according to the attributes of the object?
Interview: is bitmap pixel memory allocated in heap memory or native
如何獲取GC(垃圾回收器)的STW(暫停)時間?