-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from GihoKo/dev
Dev
- Loading branch information
Showing
7 changed files
with
115 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import axios from 'axios'; | ||
import { axiosInstanceWithToken } from '../instances'; | ||
import { axiosInstance } from '../instances'; | ||
|
||
interface RenewTokenResponse { | ||
applicationAccessToken: string; | ||
} | ||
|
||
// accessToken 만료시 token들을 재발급 | ||
export const renewTokens = async () => { | ||
try { | ||
const response = await axiosInstanceWithToken.post('/auth/renewTokens'); | ||
return response.data; | ||
const response = await axiosInstance.post<RenewTokenResponse>('/auth/renewTokens'); | ||
return response.data.applicationAccessToken; | ||
} catch (error) { | ||
if (!axios.isAxiosError(error)) { | ||
console.error('에러가 발생했습니다.'); | ||
return; | ||
} | ||
if (error.response?.status === 401) { | ||
console.error('리프레시 토큰이 만료됐습니다. 다시 로그인해주세요.'); | ||
window.location.href = '/signIn'; | ||
} | ||
console.error(error); | ||
return error; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters