当前位置:网站首页>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);
}
);
改成这种后就不再报错了
边栏推荐
- 天龙八部TLBB系列 - 关于技能冷却和攻击范围数量的问题
- RMS TO EAP通过MQTT简单实现
- 历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
- About getfragmentmanager () and getchildfragmentmanager ()
- 7 月 2 日邀你来TD Hero 线上发布会
- Unity粒子特效系列-毒液喷射预制体做好了,unitypackage包直接用 - 上
- QT timer realizes dynamic display of pictures
- tongweb设置gzip
- Observation cloud and tdengine have reached in-depth cooperation to optimize the cloud experience of enterprises
- 正式上架!TDengine 插件入驻 Grafana 官网
猜你喜欢
[200 opencv routines] 219 Add digital watermark (blind watermark)
tongweb设置gzip
历史上的今天:第一本电子书问世;磁条卡的发明者出生;掌上电脑先驱诞生...
高级 OpenCV:BGR 像素强度图
MySQL字符类型学习笔记
观测云与 TDengine 达成深度合作,优化企业上云体验
TDengine可通过数据同步工具 DataX读写
Roll up, break through 35 year old anxiety, and animate the CPU to record the function call process
Single chip microcomputer principle and Interface Technology (esp8266/esp32) machine human draft
Comment obtenir le temps STW du GC (collecteur d'ordures)?
随机推荐
Mobile heterogeneous computing technology GPU OpenCL programming (Advanced)
Matrix processing practice
美图炒币半年亏了3个亿,华为被曝在俄罗斯扩招,AlphaGo的同类又刷爆一种棋,今日更多大新闻在此...
Baidu app's continuous integration practice based on pipeline as code
How Windows bat script automatically executes sqlcipher command
Getting started with Apache dolphin scheduler (one article is enough)
[NTIRE 2022]Residual Local Feature Network for Efficient Super-Resolution
硬核,你见过机器人玩“密室逃脱”吗?(附代码)
Implementation of smart home project
从“化学家”到开发者,从甲骨文到 TDengine,我人生的两次重要抉择
Tongweb set gzip
Community group buying has triggered heated discussion. How does this model work?
Roll up, break 35 - year - old Anxiety, animation Demonstration CPU recording Function call Process
Wechat applet - simple diet recommendation (2)
H. 265 introduction to coding principles
[app packaging error] to proceed, either fix the issues identified by lint, or modify your build script as follow
La voie de l'évolution du système intelligent d'inspection et d'ordonnancement des petites procédures de Baidu
【系统设计】指标监控和告警系统
Wechat applet - simple diet recommendation (3)
百度智能小程序巡检调度方案演进之路