-
Notifications
You must be signed in to change notification settings - Fork 37
[김은경] Sprint 7,8 #283
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
The head ref may contain hidden characters: "React-\uAE40\uC740\uACBD-sprint8"
[김은경] Sprint 7,8 #283
Changes from all commits
fad8287
2700f3a
5c4f4b2
8d35b6c
c009df1
163efd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| interface Product { | ||
| page?: number; | ||
| pageSize: number; | ||
| orderBy: string; | ||
| keyword?: string; | ||
| } | ||
|
Contributor
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. 인터페이스의 값들이 query parameter들로 보이는데 ProductQueryParams 같이 이름으로 어떤 값들이 있는지 예상가능한 타입 이름이면 좋을 것 같아요. |
||
|
|
||
| interface Comment { | ||
| productSlug: string; | ||
| limit: number; | ||
| } | ||
|
Contributor
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. 위 내용과 같은 맥락에서 적절한 이름으로 수정해보시면 좋을 것 같아요. |
||
|
|
||
| export async function getProduct({ | ||
| page = 1, | ||
| pageSize = 4, | ||
| orderBy = "favorite", | ||
| keyword = "", | ||
| }: Product) { | ||
|
Contributor
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. 함수의 return 타입도 명시하면 함수를 사용하는 곳에서 어떤 타입의 값을 받게 되는지 알 수 있어 좋을 것 같아요. |
||
| //기본 URL | ||
| const baseURL = "https://panda-market-api.vercel.app/products"; | ||
| //URL 객체 | ||
| const url = new URL(baseURL); | ||
| url.searchParams.set("page", page.toString()); | ||
| url.searchParams.set("pageSize", pageSize.toString()); | ||
| url.searchParams.set("orderBy", orderBy); | ||
| url.searchParams.set("keyword", keyword); | ||
| //API 호출 | ||
| console.log(url.toString()); | ||
| const response = await fetch(url.toString()); | ||
| const data = await response.json(); | ||
| return data; | ||
| } | ||
|
|
||
| //제품 상세페이지 | ||
| export async function getProductDetail(productSlug: string) { | ||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products/${productSlug}` | ||
| ); | ||
| const data = await response.json(); | ||
| return data; | ||
| } | ||
|
|
||
| //제품 코멘트 | ||
| export async function getProductComment({ productSlug, limit }: Comment) { | ||
| const response = await fetch( | ||
| `https://panda-market-api.vercel.app/products/${productSlug}/comments?limit=${limit}` | ||
| ); | ||
| const data = await response.json(); | ||
| return data; | ||
| } | ||
This file was deleted.
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.
typescript 및 @types 라이브러리들은 프로덕션에 필요한게 아니라 빌드할 때만 필요해서
devDependencies로 변경해주시면 좋을 것 같아요.