-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
609 additions
and
60 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,14 @@ | ||
import { GetUserPostsResponse } from '@/types/apis/get'; | ||
import { AxiosResponse } from 'axios'; | ||
import { clientAuth } from './client'; | ||
|
||
export const getUserPosts = async (page: number, take: number) => { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
console.log(accessToken); | ||
const response: AxiosResponse<GetUserPostsResponse> = await clientAuth({ | ||
baseURL: 'http://13.125.101.7:8080', | ||
url: `board/mypost?page=${page}&take=${take}`, | ||
method: 'get', | ||
}); | ||
return response.data; | ||
}; |
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,15 +1,12 @@ | ||
import { getUserProfileResponse } from '@/types/apis/get'; | ||
import axios, { AxiosResponse } from 'axios'; | ||
import { AxiosResponse } from 'axios'; | ||
import { clientAuth } from './client'; | ||
|
||
export const getUserProfile = async () => { | ||
const accessToken = localStorage.getItem('accessToken'); | ||
const response: AxiosResponse<getUserProfileResponse> = await axios({ | ||
const response: AxiosResponse<getUserProfileResponse> = await clientAuth({ | ||
baseURL: 'http://13.125.101.7:8080', | ||
url: '/users/mypage', | ||
method: 'get', | ||
headers: { | ||
Authorization: `Bearer ${accessToken}`, | ||
}, | ||
}); | ||
return response.data; | ||
}; |
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
Empty file.
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,22 @@ | ||
import { getUserPosts } from '@/apis/getUserPosts'; | ||
import { GetUserPostsResponse } from '@/types/apis/get'; | ||
import { useQuery, UseQueryResult } from '@tanstack/react-query'; | ||
import axios, { AxiosError } from 'axios'; | ||
|
||
export const useGetUserPosts = (page: number, take: number): UseQueryResult<GetUserPostsResponse, AxiosError> => { | ||
return useQuery<GetUserPostsResponse, AxiosError>({ | ||
queryKey: ['get-user-posts', page, take], | ||
// queryFn: () => getUserPosts(page, take), | ||
queryFn: async () => { | ||
try { | ||
return await getUserPosts(page, take); | ||
} catch (error) { | ||
console.error('API Error:', error); | ||
if (axios.isAxiosError(error)) { | ||
console.error('Error response:', error.response?.data); | ||
} | ||
throw error; | ||
} | ||
}, | ||
}); | ||
}; |
52 changes: 39 additions & 13 deletions
52
src/pages/mypage/myPosts/myPostsContent/myPostsContent.tsx
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
Oops, something went wrong.