ky Hooks 한눈에 보기 #418
raymondanythings
started this conversation in
Today I Learned
Replies: 1 comment
-
|
axios의 interceptor와 비슷한 기능이군요! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
ky는 요청 생명주기 곳곳에 **훅(hook)**를 끼워 넣을 수 있어요.
아래 4가지 훅을 지원해요.
1. beforeRequest – 요청 보내기 직전
2. afterResponse – 응답을 받은 직후(읽기 전)
3. beforeRetry – 재시도 직전
4. beforeError – 에러 던지기 직전
아래 예시와 같이 훅을 사용할 수 있어요.
beforeRequest와 afterResponse 에서 Request, Response를 반환하면 각 요청과 응답을 교체할 수 있어요.
Beta Was this translation helpful? Give feedback.
All reactions