18 lines
409 B
TypeScript
18 lines
409 B
TypeScript
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();
|
|
}
|