-
Notifications
You must be signed in to change notification settings - Fork 20
React 강석준 sprint6 #80
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-\uAC15\uC11D\uC900-sprint6"
Changes from all commits
00fba6a
02ee1c6
da6fca5
c9babc0
651bc09
85fe1ec
14620bd
e969257
cfc800c
ce99a20
bbe8cd5
0d55e9f
66ae83f
d7cee44
a4323a7
6ad54ed
aeaf5c0
84bbc6c
7448319
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 |
|---|---|---|
|
|
@@ -22,3 +22,6 @@ dist-ssr | |
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
| # Environment variables | ||
| .env | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,20 +9,23 @@ import AddItem from "@/pages/AddItem.jsx"; | |
| import Boards from "@/pages/Boards"; | ||
| import Policy from "@/pages/Policy.jsx"; | ||
| import Faq from "@/pages/Faq.jsx"; | ||
| import Layout from "./components/MainLayout"; | ||
|
|
||
| function App() { | ||
| return ( | ||
| <StrictMode> | ||
| <BrowserRouter> | ||
| <Routes> | ||
| <Route path="/" element={<Home />}></Route> | ||
| <Route path="/login" element={<Login />}></Route> | ||
| <Route path="/signup" element={<Signup />}></Route> | ||
| <Route path="/items" element={<Items />}></Route> | ||
| <Route path="/additem" element={<AddItem />}></Route> | ||
| <Route path="/privacy" element={<Policy />}></Route> | ||
| <Route path="/faq" element={<Faq />}></Route> | ||
| <Route path="/boards" element={<Boards />}></Route> | ||
| <Route element={<Layout />}> | ||
| <Route path="/" element={<Home />} /> | ||
| <Route path="/items" element={<Items />} /> | ||
| <Route path="/additem" element={<AddItem />} /> | ||
| <Route path="/boards" element={<Boards />} /> | ||
| </Route> | ||
| <Route path="/login" element={<Login />} /> | ||
| <Route path="/signup" element={<Signup />} /> | ||
| <Route path="/privacy" element={<Policy />} /> | ||
| <Route path="/faq" element={<Faq />} /> | ||
|
Comment on lines
+19
to
+28
Collaborator
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. 우와.. 활용도가 너무 좋으신데요?라이브러리를 정말 잘 사용하시는군요 ! 👍👍👍 |
||
| </Routes> | ||
| </BrowserRouter> | ||
| </StrictMode> | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,25 +1,41 @@ | ||||||||||||||||||||
| import instance from "@/api/axiosInstance"; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const PRODUCT_ENDPOINT = `/products`; | ||||||||||||||||||||
| const IMAGE_ENDPOINT = `/images/upload`; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export const getItems = async ( | ||||||||||||||||||||
| page, | ||||||||||||||||||||
| pageSize, | ||||||||||||||||||||
| orderBy = "recent", | ||||||||||||||||||||
| keyword = null, | ||||||||||||||||||||
| ) => { | ||||||||||||||||||||
| const baseURL = "https://panda-market-api.vercel.app/products/"; | ||||||||||||||||||||
| const params = new URLSearchParams({ | ||||||||||||||||||||
| const params = { | ||||||||||||||||||||
| page: page, | ||||||||||||||||||||
| pageSize: pageSize, | ||||||||||||||||||||
| orderBy: orderBy, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (keyword) { | ||||||||||||||||||||
| params.append("keyword", keyword); | ||||||||||||||||||||
| params[keyword] = keyword; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const requrl = `${baseURL}?${params.toString()}`; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const response = await fetch(requrl, { | ||||||||||||||||||||
| method: "GET", | ||||||||||||||||||||
| const response = await instance.get(PRODUCT_ENDPOINT, { | ||||||||||||||||||||
| params: params, | ||||||||||||||||||||
| }); | ||||||||||||||||||||
| const data = await response.json(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const data = response.data; | ||||||||||||||||||||
| return data; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export const postItem = async (item) => { | ||||||||||||||||||||
| const response = await instance.post(PRODUCT_ENDPOINT, item); | ||||||||||||||||||||
| const data = response.data; | ||||||||||||||||||||
| return data; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
|
Comment on lines
+30
to
+34
Collaborator
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. (선택/소소한 팁..?) 별 건 아니지만..!
Suggested change
위와 같이 구조 분해 할당으로 간략히 작성할 수 있습니다 ! 😊
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| export const uploadImage = async (image) => { | ||||||||||||||||||||
| const response = await instance.post(IMAGE_ENDPOINT, { image }); | ||||||||||||||||||||
| const data = response.data; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return data; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import axios from "axios"; | ||
|
|
||
| const API_BASE_URL = import.meta.env.VITE_API_BASE_URL; | ||
|
|
||
| const axiosInstance = axios.create({ | ||
| baseURL: API_BASE_URL, | ||
| headers: { | ||
| "Content-Type": "application/json", | ||
| }, | ||
| }); | ||
|
|
||
| export default axiosInstance; |
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.
굿굿 ! 환경 변수를 추가하고
gitignore에 추가하셨군요 ! 👍