-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/#511 프론트의 토큰 만료 검증로직을 삭제하고 Axios를 도입한다. #554
Changes from 1 commit
3ec2b5f
895be60
69605c1
89bdb5f
e10bfbe
f2c79ee
3ecd234
db04ff0
a2bbcee
c287cfe
d06887a
a4a83df
4f858e9
09cf9f3
e6bfcfe
744fbff
2166a72
8e0a22f
0fbcfde
6755702
0f87b75
dbf9655
500cae1
ea5e89b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { Comment } from '../types/comment.type'; | ||
|
||
export const postComment = async (songId: number, partId: number, content: string) => { | ||
await fetcher(`/songs/${songId}/parts/${partId}/comments`, 'POST', { content }); | ||
await client.post(`/songs/${songId}/parts/${partId}/comments`, { content }); | ||
}; | ||
|
||
export const getComments = async (songId: number, partId: number): Promise<Comment[]> => { | ||
return await fetcher(`/songs/${songId}/parts/${partId}/comments`, 'GET'); | ||
export const getComments = async (songId: number, partId: number) => { | ||
const { data } = await client.get<Comment[]>(`/songs/${songId}/parts/${partId}/comments`); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { KillingPartPostRequest } from '@/shared/types/killingPart'; | ||
|
||
export const postKillingPart = async (songId: number, body: KillingPartPostRequest) => { | ||
return await fetcher(`/songs/${songId}/member-parts`, 'POST', body); | ||
await client.post(`/songs/${songId}/member-parts`, body); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { SongInfo } from '@/shared/types/song'; | ||
|
||
// PartCollectingPage에 존재하던 remote 함수입니다. | ||
// useFetch<SongInfo>(() => fetcher(`/songs/${songId}`, 'GET')) 로직에서 분리하였습니다. | ||
// SongInfo type에는 killingPart[] 필드가 있는데, 마이파트 수집용 `노래 1개` 조회에서 해당 타입이 사용되고 있습니다. | ||
// 추후 수정되어야 합니다. | ||
export const getSong = async (songId: number): Promise<SongInfo> => { | ||
return await fetcher(`/songs/${songId}`, 'GET'); | ||
|
||
export const getSong = async (songId: number) => { | ||
const { data } = await client.get<SongInfo>(`/songs/${songId}`); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
|
||
export const deleteMember = (memberId: number | undefined) => () => { | ||
return fetcher(`/members/${memberId}`, 'DELETE'); | ||
export const deleteMember = async (memberId: number) => { | ||
await client.delete(`/members/${memberId}`); | ||
}; | ||
Comment on lines
+3
to
5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. useMutaion의 타입을 맞추려다보니 그렇습니다~ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
|
||
export const deleteMemberParts = (partId: number) => fetcher(`/member-parts/${partId}`, 'DELETE'); | ||
export const deleteMemberParts = async (partId: number) => { | ||
await client.delete(`/member-parts/${partId}`); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { LikeKillingPart } from '../components/MyPartList'; | ||
|
||
export const getLikeParts = () => fetcher('/my-page/like-parts', 'GET'); | ||
export const getLikeParts = async () => { | ||
const { data } = await client.get<LikeKillingPart[]>('/my-page/like-parts'); | ||
|
||
export const getMyParts = () => fetcher('/my-page/my-parts', 'GET'); | ||
return data; | ||
}; | ||
|
||
export const getMyParts = async () => { | ||
const { data } = await client.get<LikeKillingPart[]>('/my-page/my-parts'); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { SingerDetail } from '../../singer/types/singer.type'; | ||
import type { SingerSearchPreview } from '../types/search.type'; | ||
|
||
export const getSingerSearchPreview = async (query: string): Promise<SingerSearchPreview[]> => { | ||
export const getSingerSearchPreview = async (query: string) => { | ||
const encodedQuery = encodeURIComponent(query); | ||
return await fetcher(`/search?keyword=${encodedQuery}&type=singer`, 'GET'); | ||
const { data } = await client.get<SingerSearchPreview[]>( | ||
`/search?keyword=${encodedQuery}&type=singer` | ||
); | ||
|
||
return data; | ||
}; | ||
|
||
export const getSingerSearch = async (query: string): Promise<SingerDetail[]> => { | ||
export const getSingerSearch = async (query: string) => { | ||
const encodedQuery = encodeURIComponent(query); | ||
return await fetcher(`/search?keyword=${encodedQuery}&type=singer&type=song`, 'GET'); | ||
const { data } = await client.get<SingerDetail[]>( | ||
`/search?keyword=${encodedQuery}&type=singer&type=song` | ||
); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { SingerDetail } from '../types/singer.type'; | ||
|
||
export const getSingerDetail = async (singerId: number): Promise<SingerDetail> => { | ||
return await fetcher(`/singers/${singerId}`, 'GET'); | ||
export const getSingerDetail = async (singerId: number) => { | ||
const { data } = await client.get<SingerDetail>(`/singers/${singerId}`); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
|
||
export const putKillingPartLikes = async (songId: number, partId: number, likeStatus: boolean) => { | ||
return await fetcher(`/songs/${songId}/parts/${partId}/likes`, 'PUT', { likeStatus }); | ||
await client.put(`/songs/${songId}/parts/${partId}/likes`, { likeStatus }); | ||
}; | ||
Comment on lines
3
to
5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 mutation 함수를 확인해보니 타입이 export const useMutation = <T, P extends any[]>(mutateFn: (...params: P) => Promise<T>) => {
const [data, setData] = useState<T | null>(null);
const [isLoading, setIsLoading] = useState(false);
// ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { Genre, Song } from '../types/Song.type'; | ||
import type { RecentSong } from '@/shared/types/song'; | ||
|
||
// 메인 케러셀 최신순 노래 n개 조회 api - 쿼리파람 없는경우, 응답 기본값은 5개입니다. | ||
export const getRecentSongs = async (songCount?: number): Promise<RecentSong[]> => { | ||
export const getRecentSongs = async (songCount?: number) => { | ||
const query = songCount ? `?size=${songCount}` : ''; | ||
|
||
return await fetcher(`/songs/recent${query}`, 'GET'); | ||
const { data } = await client.get<RecentSong[]>(`/songs/recent${query}`); | ||
|
||
return data; | ||
}; | ||
|
||
export const getHighLikedSongs = async (genre: Genre): Promise<Song[]> => { | ||
export const getHighLikedSongs = async (genre: Genre) => { | ||
const query = genre === 'ALL' ? '' : `?genre=${genre}`; | ||
|
||
return await fetcher(`/songs/high-liked${query}`, 'GET'); | ||
const { data } = await client.get<Song[]>(`/songs/high-liked${query}`); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
import fetcher from '@/shared/remotes'; | ||
import client from '@/shared/remotes/axios'; | ||
import type { Genre } from '../types/Song.type'; | ||
import type { SongDetail, SongDetailEntries } from '@/shared/types/song'; | ||
|
||
export const getSongDetailEntries = async ( | ||
songId: number, | ||
genre: Genre | ||
): Promise<SongDetailEntries> => { | ||
export const getSongDetailEntries = async (songId: number, genre: Genre) => { | ||
const query = genre === 'ALL' ? '' : `?genre=${genre}`; | ||
return await fetcher(`/songs/high-liked/${songId}${query}`, 'GET'); | ||
const { data } = await client.get<SongDetailEntries>(`/songs/high-liked/${songId}${query}`); | ||
|
||
return data; | ||
}; | ||
|
||
export const getExtraPrevSongDetails = async ( | ||
songId: number, | ||
genre: Genre | ||
): Promise<SongDetail[]> => { | ||
export const getExtraPrevSongDetails = async (songId: number, genre: Genre) => { | ||
const query = genre === 'ALL' ? '' : `?genre=${genre}`; | ||
return await fetcher(`/songs/high-liked/${songId}/prev${query}`, 'GET'); | ||
const { data } = await client.get<SongDetail[]>(`/songs/high-liked/${songId}/prev${query}`); | ||
|
||
return data; | ||
}; | ||
|
||
export const getExtraNextSongDetails = async ( | ||
songId: number, | ||
genre: Genre | ||
): Promise<SongDetail[]> => { | ||
export const getExtraNextSongDetails = async (songId: number, genre: Genre) => { | ||
const query = genre === 'ALL' ? '' : `?genre=${genre}`; | ||
return await fetcher(`/songs/high-liked/${songId}/next${query}`, 'GET'); | ||
const { data } = await client.get<SongDetail[]>(`/songs/high-liked/${songId}/next${query}`); | ||
|
||
return data; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 제네릭이 필요 없어졌다면 useFetch도 수정해야되지 않을까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
어떤 식으로 수정이 되어야할까요? 생각나는 방향이 있으시면 같이 알려주세용
제네릭 없이도 useFetch data 타입이 추론 될지 모르겠네용