当前位置:网站首页>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
边栏推荐
- Apache dolphin scheduler system architecture design
- 【C语言】动态内存开辟的使用『malloc』
- Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 - 上
- Comment obtenir le temps STW du GC (collecteur d'ordures)?
- View Slide
- Design of stepping motor controller based on single chip microcomputer (forward rotation and reverse rotation indicator gear)
- Cent7 Oracle database installation error
- Generics, generic defects and application scenarios that 90% of people don't understand
- oracle和mysql批量Merge对比
- [app packaging error] to proceed, either fix the issues identified by lint, or modify your build script as follow
猜你喜欢
苹果 5G 芯片研发失败?想要摆脱高通为时过早
自动化规范检查软件如何发展而来?
ConstraintLayout的流式布局Flow
Energy momentum: how to achieve carbon neutralization in the power industry?
The comparison of every() and some() in JS uses a power storage plan
Cut off 20% of Imagenet data volume, and the performance of the model will not decline! Meta Stanford et al. Proposed a new method, using knowledge distillation to slim down the data set
mysql80服务不启动
View Slide
MySQL字符类型学习笔记
cent7安装Oracle数据库报错
随机推荐
Theme. AppCompat. Light. Darkactionbar not found
【OpenCV 例程200篇】219. 添加数字水印(盲水印)
Design of stepping motor controller based on single chip microcomputer (forward rotation and reverse rotation indicator gear)
一个程序员的职业生涯到底该怎么规划?
【小技巧】获取matlab中cdfplot函数的x轴,y轴的数值
Usage differences between isempty and isblank
@Jsonadapter annotation usage
How Windows bat script automatically executes sqlcipher command
The horizontally scrolling recycleview displays five and a half on one screen, lower than the average distribution of five
Kotlin Compose 与原生 嵌套使用
天龙八部TLBB系列 - 关于包裹掉落的物品
Fluent development: setting method of left and right alignment of child controls in row
【C语言】动态内存开辟的使用『malloc』
[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution
Matrix processing practice
Windows uses commands to run kotlin
如何判断线程池已经执行完所有任务了?
把欧拉的创新带向世界 SUSE 要做那个引路人
ArcGIS Pro 创建要素
【JS】数组降维