File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 11import axios from 'axios' ;
22
33import { useAuthStore } from '@/features/auth' ;
4+ import { PostRefreshResponseDTO } from '@/features/auth/auth.dto' ;
45
56axios . interceptors . request . use (
67 ( config ) => {
@@ -28,17 +29,15 @@ axios.interceptors.response.use(
2829 credentials : 'include' ,
2930 } ) ;
3031
31- const { type, data : result } = ( await response . json ( ) ) as {
32- type : 'success' | 'fail' ;
33- data : { accessToken : string } ;
34- } ;
32+ const { accessToken, userId } =
33+ ( await response . json ( ) ) as PostRefreshResponseDTO ;
3534
3635 const { setAuthInformation, clearAuthInformation } =
3736 useAuthStore . getState ( ) ;
3837
39- if ( type === 'success' && result . accessToken ) {
40- setAuthInformation ( result ) ;
41- originalRequest . headers . Authorization = `Bearer ${ result . accessToken } ` ;
38+ if ( accessToken ) {
39+ setAuthInformation ( { accessToken , userId } ) ;
40+ originalRequest . headers . Authorization = `Bearer ${ accessToken } ` ;
4241 return axios ( originalRequest ) ;
4342 }
4443
You can’t perform that action at this time.
0 commit comments