Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- 장점
- 코딩기초트레이닝
- 장단점
- 단점
- 스파르타코딩클럽
- 부트캠프
- input
- 개념
- 프로그래머스
- 특징
- 과제
- backjun
- 비교
- React
- 문법
- Android
- Redux
- 종류
- 안드로이드
- 코틀린
- Promise
- 차이점
- 코딩 기초 트레이닝
- 자바스크립트
- javascript
- 의미
- programmers
- 리액트
- 항해99
- 웹개발종합반
Archives
COCO World
[React] Cannot read properties of undefined (reading 'cancelToken') 해결 본문
에러 기록지
[React] Cannot read properties of undefined (reading 'cancelToken') 해결
코코월드주인장 2023. 3. 8. 23:15에러 발생
리액트 실행 중 'Cannot read properties of undefined (reading 'cancelToken')' 에러가 발생했다.
원인은 axios의 interceptor를 사용하는 와중에 깜빡하고 return을 넣어주지 않았기 때문이다.
instance.interceptors.request.use(
function(config) {
console.log(config)
const token = getCookie('userCookie')
if ( token ) {
config.headers.authorization = token
}
}
)
해결 방안
return 값을 넣어주자.
instance.interceptors.request.use(
function(config) {
console.log(config)
const token = getCookie('userCookie')
if ( token ) {
config.headers.authorization = token
}
return config;
}
)