Download client/src/api.ts from AK270802/ChatMind: direct link, hf CLI and curl.
- Browser
- Download file 550 Bytes
-
https://huggingface.co/spaces/AK270802/ChatMind/resolve/main/client/src/api.ts
- Command line
-
hf download hf://spaces/AK270802/ChatMind/client/src/api.ts
-
curl -L -o api.ts https://huggingface.co/spaces/AK270802/ChatMind/resolve/main/client/src/api.ts
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(); | |
| } | |