Typescript AxiosError response.data의 내부 type 지정 관련 질문 #636
Answered
by
woohm402
HyeongtaekOh
asked this question in
Q&A
-
axios를 이용하는 함수의 오류처리 catch문에서 API 서버에서 돌아오는 error message를 기반으로 에러 토스트를 띄우고 있는데 해당 부분을 Typescript로 바꾸려하니 아래처럼 error response의 data type이 지정되어있지 않아 오류가 뜨는데 AxiosError의 내부 type을 지정할 수 있는 방법이 있나요? |
Beta Was this translation helpful? Give feedback.
Answered by
woohm402
Nov 5, 2021
Replies: 1 comment 4 replies
-
이전가지의 해결방법과 마찬가지로 해당 부분 소스 를 보면 generic을 이용해 어떻게 잘 구현되어 있단 걸 확인할 수 있습니다. e as AxiosError<뭔가> 로 |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
HyeongtaekOh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
이전가지의 해결방법과 마찬가지로 해당 부분 소스 를 보면 generic을 이용해 어떻게 잘 구현되어 있단 걸 확인할 수 있습니다.
로
T
를 잡아주시면 됩니다.