Files
imphnen-frontend-service/apps/landing/src/app/(auth)/signin/_http/fetch-post-signin.ts
T

25 lines
501 B
TypeScript
Raw Normal View History

import { fetcher } from '@/lib/fetcher';
import { SignInValidationType } from '../_validation/signin-validation';
export async function fetchPostSignin({
email,
password,
}: SignInValidationType) {
const { data, error, response } = await fetcher.POST('/v1/auth/login', {
body: {
email,
password,
},
});
if (error) {
throw new Error(error.message);
}
if (!response.ok) {
throw new Error('Someting went wrong, please try again later');
}
return data;
}