forked from SWYP-team-2th/client
-
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.
토큰에 추가된 userId를 반영하여 로그인 성공 시 유저 고유의 마이페이지로 리다이렉트 한다. (SWYP-team-2th#131
- Loading branch information
Showing
4 changed files
with
39 additions
and
22 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { request } from '@/api/config'; | ||
import { getAccessToken } from '@/components/login/Auth/token'; | ||
|
||
interface IdentificationInfoResponse { | ||
id: number; | ||
nickname: string; | ||
profileUrl: string; | ||
} | ||
|
||
export default function useGetIdentificationInfo() { | ||
return useQuery<IdentificationInfoResponse>({ | ||
queryKey: ['identificationInfo'], | ||
queryFn: async () => { | ||
const token = getAccessToken(); | ||
return request<IdentificationInfoResponse>({ | ||
method: 'GET', | ||
url: '/users/me', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}, | ||
// 토큰이 저장되도 여기 쿼리문이 실행되지 않기 때문에 토큰이 들어오면 현재 쿼리문 실행되도록 설정 | ||
enabled: !!getAccessToken(), | ||
}); | ||
} |
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