Add helpers and types for BFF API
This commit is contained in:
parent
d626c2a498
commit
9dbd93a430
5 changed files with 89 additions and 0 deletions
18
lib/api/helpers/users.ts
Normal file
18
lib/api/helpers/users.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
export async function getUsers() {
|
||||
const response = await fetch("/api/users");
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function getUser(id: number) {
|
||||
const response = await fetch(`/api/users/${id}`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Response status: ${response.status}`);
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
Loading…
Reference in a new issue