ChatMind / client /src /api.ts
r2hummingbird's picture
Initial commit - ChatMind Trading Platform
e8de0f8
Raw History Blame Contribute Delete
550 Bytes
// frontend/src/api.ts
export const api = {
login,
getUser,
};
export async function login(email: string, password: string) {
const res = await fetch("/api/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
credentials: "include", // important to send session cookie
body: JSON.stringify({ email, password })
});
return res.json();
}
export async function getUser() {
const res = await fetch("/api/user", {
method: "GET",
credentials: "include" // important!
});
return res.json();
}