-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
28 lines (26 loc) · 695 Bytes
/
api.js
File metadata and controls
28 lines (26 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
export function getTodos() {
return fetch("https://webdev-hw-api.vercel.app/api/todos", {
method: "GET",
}).then((response) => {
return response.json();
});
}
export function deleteTodo({ id }) {
return fetch("https://webdev-hw-api.vercel.app/api/todos/" + id, {
method: "DELETE",
})
.then((response) => {
return response.json();
})
}
export function postTodo({ text }) {
return fetch("https://webdev-hw-api.vercel.app/api/todos", {
method: "POST",
body: JSON.stringify({
text: text,
}),
})
.then((response) =>{
return response.json();
})
}