implement basic login
This commit is contained in:
parent
bdd90b50d9
commit
7a6f5b5bcd
18 changed files with 222 additions and 35 deletions
27
frontend/src/api/points/AuthPoint.ts
Normal file
27
frontend/src/api/points/AuthPoint.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
import type { Recipe } from "../../types/recipe"
|
||||
import type { LoginRequestDto } from "../dtos/LoginRequestDto";
|
||||
import type { LoginResponseDto } from "../dtos/LoginResponseDto";
|
||||
import { get, postJson, putJson } 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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue