Potion/web/src/services/RecipeService.ts
Hayden Hargreaves 25ea3fcfd7 (FEAT): JWT auth is coming along so well!
We have it in the UI, just need a way to send it back and handle it in
the backend.
2025-11-13 22:57:05 -07:00

20 lines
622 B
TypeScript

import axios from "axios";
import type { GetRecipeOfTheWeekResponse } from "../types/api/recipe";
import type { Recipe } from "../types/recipe";
import type { ApiError } from "../types/api/error";
export async function GetRecipeOfTheWeek (): Promise<Recipe | ApiError> {
const response = await axios.get<GetRecipeOfTheWeekResponse>("http://localhost:3000/v2/api/recipe/of-the-week");
if (response.status !== 200 || response.data.recipe === undefined) {
const err: ApiError = {
status: response.data.status,
message: response.data.message
};
return err;
}
return response.data.recipe;
}