-
Notifications
You must be signed in to change notification settings - Fork 24
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
1 parent
94fdaee
commit c853d33
Showing
10 changed files
with
140 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
export const BASE_URL = new URL('https://panda-market-api.vercel.app/'); | ||
|
||
type FetchReqPrams = { | ||
method: 'GET' | 'POST' | 'PATCH' | 'DELETE'; | ||
path: string; | ||
payload?: Record<string, unknown>; | ||
} | ||
|
||
export const fetchReq = async (params: FetchReqPrams) => { | ||
const { method, path, payload } = params; | ||
const options = { | ||
method, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'cors': 'no-cors', | ||
}, | ||
body: payload ? JSON.stringify(payload) : null, | ||
}; | ||
try { | ||
const response = await fetch(path, options); | ||
if (!response.ok) { | ||
throw new Error(`HTTP error status ${response?.status}`); | ||
} | ||
return response.json(); | ||
} catch (error) { | ||
console.error(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,18 @@ | ||
// @ts-nocheck | ||
const base_url = 'https://panda-market-api.vercel.app/'; | ||
const api_url = `${base_url}products`; | ||
import { BASE_URL, fetchReq } from './fetch.js'; | ||
|
||
type OrderType = 'favorite' | 'recent' | ||
type QueryObjType = { | ||
page?: number; | ||
pageSize?: number; | ||
orderBy?: OrderType; | ||
keyword?: string; | ||
} | ||
|
||
|
||
export const getProductList = (queryObj: QueryObjType) => { | ||
const queryStr = new URLSearchParams(queryObj as Record<string, string>); | ||
return fetchReq({ | ||
method: 'GET', | ||
path: `${BASE_URL}products?${queryStr}`, | ||
}); | ||
}; |
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
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 +1,19 @@ | ||
{"root":["./src/app.tsx","./src/error-page.tsx","./src/main.tsx","./src/vite-env.d.ts","./src/apis/products.ts","./src/components/defaultbtn.tsx","./src/components/dropdown.tsx","./src/components/footer.tsx","./src/components/header.tsx","./src/components/itemcard.tsx","./src/components/logo.tsx","./src/components/pagination.tsx","./src/components/serach.tsx","./src/routes/items.tsx","./src/routes/root.tsx"],"version":"5.6.3"} | ||
{ | ||
"root": [ | ||
"./src/app.tsx", | ||
"./src/error-page.tsx", | ||
"./src/main.tsx", | ||
"./src/vite-env.d.ts", | ||
"./src/apis/products.ts", | ||
"./src/components/footer.tsx", | ||
"./src/components/header.tsx", | ||
"./src/components/itemcard.tsx", | ||
"./src/components/logo.tsx", | ||
"./src/components/pagination.tsx", | ||
"./src/components/searchinput.tsx", | ||
"./src/components/sortselection.tsx", | ||
"./src/routes/items.tsx", | ||
"./src/routes/root.tsx" | ||
], | ||
"version": "5.6.3" | ||
} |
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,12 @@ | ||
export interface ItemCardProps { | ||
createdAt: string; | ||
description: string; | ||
favoriteCount: number; | ||
id: number; | ||
images: string[]; | ||
name: string; | ||
ownerId: number; | ||
price: number; | ||
tags: string[]; | ||
updatedAt: string; | ||
} |