26 lines
660 B
TypeScript
26 lines
660 B
TypeScript
import type { LoginRequestDto } from "../dtos/LoginRequestDto";
|
|
import type { LoginResponseDto } from "../dtos/LoginResponseDto";
|
|
import { postJson } from "../utils/requests";
|
|
|
|
|
|
/**
|
|
* Util for handling the recipe api
|
|
*/
|
|
// read base url from .env file
|
|
const BASE_URL = import.meta.env.VITE_API_BASE;
|
|
|
|
/**
|
|
* URL for handling recipes
|
|
*/
|
|
const AUTH_URL = `${BASE_URL}/auth`
|
|
|
|
|
|
/**
|
|
* Create new Recipe
|
|
* @param recipe Recipe to create
|
|
* @returns Saved recipe
|
|
*/
|
|
export async function login(requestDto: LoginRequestDto): Promise<LoginResponseDto> {
|
|
const res = await postJson(`${AUTH_URL}/login`, JSON.stringify(requestDto), false);
|
|
return res.json();
|
|
}
|