Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions 4th/1번/1.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## 백엔드로 필요한 데이터를 요청하기 위해 가장 필요한 2가지는? (백엔드 개발자의 문서를 통해서 확인해야 하는 2가지 입니다)

(여기에 작성하세요)
API 주소와 메소드 (method)가 필요합니다.
1 change: 1 addition & 0 deletions 4th/2번/2.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## REST API의 GET 메소드에 대해 아는데로 작성해보세요.

(여기에 작성하세요)
서버로부터 정보를 가져오고, 데이터를 조회할 때 사용되며, 서버의 상태나 데이터를 변경하지 않습니다.
1 change: 1 addition & 0 deletions 4th/3번/3.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
## REST API의 POST 메소드에 대해 아는데로 작성해보세요.

(여기에 작성하세요)
새로운 데이터를 생성하거나 리소스를 업데이트할 때 사용합니다.
16 changes: 8 additions & 8 deletions 4th/4번/4.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
## REST API의 의미를 고려할 때, 다음 API 주소들의 의미는 무엇일지 추측해보세요. (정답이 아니라 추측하는 겁니다)

1. `https://dummyjson.com/products` (method: GET)
-
- products의 리스트를 불러오라는 의미
2. `https://dummyjson.com/products/1` (method: GET)
-
- products의 첫번째 product를 불러오라는 의미
3. `https://dummyjson.com/products/search?q=phone` (method: GET)
-
- products에서 phone과 관련된 걸 불러오라는 의미
4. `https://dummyjson.com/products/categories` (method: GET)
-
- products의 categories를 불러오라는 의미
5. `https://dummyjson.com/products/category/smartphones` (method: GET)
-
- products의 categories에서 smartphones와 관련된걸 불러오라는 의미
6. `https://dummyjson.com/products/add` (method: POST)
-
- products에 새로운 걸 추가하겠다는 의미
7. `https://dummyjson.com/products/1` (method: PUT)
-
- products에서 첫번째 products를 수정하겠다는 의미
8. `https://dummyjson.com/products/1` (method: DELETE)
-
- products에서 첫번째 products를 삭제하겠다는 의미
25 changes: 25 additions & 0 deletions 4th/5번/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
// 여기에 1번 문제의 답을 작성하세요.
const getProducts = async () => {
const res = await fetch("https://dummyjson.com/products");
const data = await res.json();
return data;
};

// 여기에 2번 문제의 답을 작성하세요.

const addProduct = async () => {
try {
const response = await fetch("https://dummyjson.com/products/add", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
title: "BMW Pencil",
/* other product data */
}),
});

const data = await response.json();
console.log(data);
} catch (error) {
console.log("Error: error입니다.", error.message);
}
};

addProduct();