-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from tonitienda/feat/list-tasks
feat: list user tasks
- Loading branch information
Showing
10 changed files
with
151 additions
and
350 deletions.
There are no files selected for viewing
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,8 +1,14 @@ | ||
POST http://localhost:8080/tasks | ||
POST http://localhost:8080/v0/tasks | ||
Content-Type: application/json | ||
X-User-ID: b78fe6be-0642-4cfa-9f19-9cc8e53b129d | ||
|
||
{ | ||
"title": "Task 1", | ||
"description": "Task 1 description" | ||
} | ||
} | ||
|
||
### | ||
|
||
GET http://localhost:8080/v0/tasks | ||
Content-Type: application/json | ||
X-User-ID: b78fe6be-0642-4cfa-9f19-9cc8e53b129d |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,41 @@ | ||
export async function getTasks() { | ||
const res = await fetch("http://localhost:8080/v0/tasks?t=1", { | ||
cache: "no-store", | ||
headers: { | ||
"X-User-ID": "b78fe6be-0642-4cfa-9f19-9cc8e53b129d", | ||
}, | ||
}); | ||
// The return value is *not* serialized | ||
// You can return Date, Map, Set, etc. | ||
|
||
if (!res.ok) { | ||
// This will activate the closest `error.js` Error Boundary | ||
throw new Error("Failed to fetch data"); | ||
} | ||
|
||
return res.json(); | ||
} | ||
|
||
export async function addTask() { | ||
const res = await fetch("http://localhost:8080/v0/tasks", { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
title: "New task", | ||
description: "This is a new task", | ||
}), | ||
|
||
headers: { | ||
"X-User-ID": "b78fe6be-0642-4cfa-9f19-9cc8e53b129d", | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
// The return value is *not* serialized | ||
// You can return Date, Map, Set, etc. | ||
|
||
if (!res.ok) { | ||
// This will activate the closest `error.js` Error Boundary | ||
throw new Error("Failed to add task"); | ||
} | ||
|
||
return res.json(); | ||
} |
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
Oops, something went wrong.