incription , connection

This commit is contained in:
Emma781227
2026-06-16 11:22:03 +02:00
parent 72e7771d95
commit 25be38027d
5 changed files with 294 additions and 131 deletions

View File

@@ -0,0 +1,23 @@
const BASE = '/api/auth'
export async function loginApi({ email, password }) {
const res = await fetch(`${BASE}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
})
const data = await res.json()
if (!res.ok) throw new Error(data.message || 'Erreur de connexion.')
return data
}
export async function registerApi({ email, firstname, lastname, password }) {
const res = await fetch(`${BASE}/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, firstname, lastname, password }),
})
const data = await res.json()
if (!res.ok) throw new Error(data.message || "Erreur lors de l'inscription.")
return data
}