当前位置:网站首页>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);
}
);
改成这种后就不再报错了
边栏推荐
- Coordinate system of view
- Cent7 Oracle database installation error
- Apache dolphin scheduler system architecture design
- Tdengine can read and write through dataX, a data synchronization tool
- 如何獲取GC(垃圾回收器)的STW(暫停)時間?
- 基于模板配置的数据可视化平台
- 宝塔面板MySQL无法启动
- 解决Navicat激活、注册时候出现No All Pattern Found的问题
- Tutorial on building a framework for middle office business system
- Analysis on the wallet system architecture of Baidu trading platform
猜你喜欢

Online chain offline integrated chain store e-commerce solution

From "chemist" to developer, from Oracle to tdengine, two important choices in my life
![[C language] the use of dynamic memory development](/img/b7/3337bf0df9232d3a44eaeb46b39c63.png)
[C language] the use of dynamic memory development "malloc"

The writing speed is increased by dozens of times, and the application of tdengine in tostar intelligent factory solution

Evolution of Baidu intelligent applet patrol scheduling scheme

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

Tdengine connector goes online Google Data Studio app store

基于模板配置的数据可视化平台

Data visualization platform based on template configuration

Node-RED系列(二九):使用slider与chart节点来实现双折线时间序列图
随机推荐
Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 - 上
Data visualization platform based on template configuration
Community group buying has triggered heated discussion. How does this model work?
Charm of code language
QT realizes signal transmission and reception between two windows
What should we pay attention to when developing B2C websites?
Wechat applet - simple diet recommendation (3)
宝塔面板MySQL无法启动
Officially launched! Tdengine plug-in enters the official website of grafana
Kotlin compose and native nesting
ThreadLocal source code learning
Meitu lost 300 million yuan in currency speculation for half a year. Huawei was exposed to expand its enrollment in Russia. Alphago's peers have made another breakthrough in chess. Today, more big new
TDengine 离线升级流程
The most comprehensive promotion strategy: online and offline promotion methods of E-commerce mall
TDengine ×英特尔边缘洞见软件包 加速传统行业的数字化转型
为什么不建议你用 MongoDB 这类产品替代时序数据库?
The writing speed is increased by dozens of times, and the application of tdengine in tostar intelligent factory solution
Tutorial on building a framework for middle office business system
idea用debug调试出现com.intellij.rt.debugger.agent.CaptureAgent,导致无法进行调试
Why do offline stores need cashier software?