27 lines
527 B
JavaScript

const BASE_URL = "http://localhost:3000/api";
export async function register(username) {
const res = await fetch(`${BASE_URL}/user`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ username })
});
return res.json();
}
export async function login(username, password) {
const res = await fetch(`${BASE_URL}/user`, {
method: "GET",
headers: {
"X-Username": username,
"X-Password": password
}
});
return res.status === 201;
}