From 94204120591e3edf52f79203db2f6d1536df67a5 Mon Sep 17 00:00:00 2001 From: siwolee Date: Mon, 2 Sep 2024 22:12:31 +0900 Subject: [PATCH] test: axios 401 --- hooks/useAxiosResponse.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hooks/useAxiosResponse.ts b/hooks/useAxiosResponse.ts index 7a43a5299..822f83176 100644 --- a/hooks/useAxiosResponse.ts +++ b/hooks/useAxiosResponse.ts @@ -2,7 +2,7 @@ import { AxiosError, AxiosResponse } from 'axios'; import Cookies from 'js-cookie'; import { useEffect, useState } from 'react'; import { useSetRecoilState } from 'recoil'; -import { instance } from 'utils/axios'; +import { instance, instanceInAgenda } from 'utils/axios'; import { errorState } from 'utils/recoil/error'; import { loginState } from 'utils/recoil/login'; @@ -50,6 +50,11 @@ export default function useAxiosResponse() { (response: AxiosResponse) => response, errorResponseHandler ); + const responseInAgendaInterceptor = + instanceInAgenda.interceptors.response.use( + (response: AxiosResponse) => response, + errorResponseHandler + ); useEffect(() => { if (localStorage.getItem('42gg-token')) { @@ -63,6 +68,7 @@ export default function useAxiosResponse() { useEffect(() => { return () => { instance.interceptors.response.eject(responseInterceptor); + instance.interceptors.response.eject(responseInAgendaInterceptor); }; - }, [responseInterceptor]); + }, [responseInterceptor, responseInAgendaInterceptor]); }