wedding-planner-frontend/app/api/authentication.tsx

15 lines
489 B
TypeScript
Raw Normal View History

import { getCsrfToken } from '@/app/lib/utils';
export function login({ email, password, onLogin }: { email: string, password: string, onLogin: () => void }) {
console.log(email, password);
return fetch("/api/default/users/sign_in", {
method: 'POST',
body: JSON.stringify({ user: { email, password } }),
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': getCsrfToken(),
}
})
.then(onLogin)
.catch((error) => console.error(error));
}