-
Notifications
You must be signed in to change notification settings - Fork 9
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
나무 1주차 #32
나무 1주차 #32
Changes from all commits
f5579fd
9726927
27acab3
e54355c
19f78d2
171bbb4
781dc0d
6dab52f
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.
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,5 @@ | ||
export const METHOD = { | ||
GET: "GET", | ||
POST: "POST", | ||
DELETE: "DELETE", | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const BASE_SERVER_URL = "http://localhost:3000"; | ||
export const BASE_CLIENT_URL = "http://localhost:5510"; | ||
|
||
export const FOX_URL = "https://randomfox.ca"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { METHOD } from "../constant/api"; | ||
|
||
export async function postAsync(url: string, data: object) { | ||
return getParsedData(url, getConfig(METHOD.POST, data)); | ||
} | ||
|
||
export async function getAsync(url: string, data: object) { | ||
return getParsedData(url, getConfig(METHOD.GET, data)); | ||
} | ||
|
||
export async function deleteAsync(url: string, data: object) { | ||
return getParsedData(url, getConfig(METHOD.DELETE, data)); | ||
} | ||
|
||
function getConfig(method: string, data: object) { | ||
return { | ||
method: method, | ||
headers: new Headers({ "content-type": "application/json" }), | ||
body: data && JSON.stringify(data), | ||
Comment on lines
+18
to
+19
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. && 연산자로 초기화한 부분👍👍 |
||
}; | ||
} | ||
|
||
async function getParsedData(url: string, config: object) { | ||
const response = await fetch(url, config); | ||
return await response.json(); | ||
} | ||
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. 오 parsed 부분와 config 를 이렇게 나누면 나중에 재활용하거나 활용하기 좋아 보이네용 굳굳 👍🏻 |
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.
await 키워드가 없는 함수에 async 가 붙어있네용?. ?
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.
핚 이런 날카로운 리뷰..^^ my (옛)pair답군요 감사합니당!!