checkpoint

This commit is contained in:
fred 2025-08-14 13:05:57 -07:00
parent 24281a6322
commit 5dc89497c6
16 changed files with 1427 additions and 15 deletions

View file

@ -1,27 +1,27 @@
const baseUrl = process.env.NODE_ENV !== 'dev'
? '/'
: 'http://localhost:3000/';
const baseUrl =
process.env.NODE_ENV !== "dev" ? "/api" : "http://localhost:3000/api";
export const getRecipes = async () => {
const response = await fetch(`${baseUrl}backend/recipes`);
console.log(`${baseUrl}/recipes`);
const response = await fetch(`${baseUrl}/recipes`);
const data = await response.json();
return data;
};
export const getRecipeSteps = async () => {
const response = await fetch(`${baseUrl}backend/recipe-steps`);
const response = await fetch(`${baseUrl}/recipe-steps`);
const data = await response.json();
return data;
};
export const getRecipeIngredients = async () => {
const response = await fetch(`${baseUrl}backend/recipe-ingredients`);
const response = await fetch(`${baseUrl}/recipe-ingredients`);
const data = await response.json();
return data;
};
export const getRecipeById = async (id) => {
const response = await fetch(`${baseUrl}backend/recipe/${id}`);
const response = await fetch(`${baseUrl}/recipe/${id}`);
const data = await response.json();
if (!data || !data.details) {
return { details: null };
@ -32,7 +32,7 @@ export const getRecipeById = async (id) => {
export const addRecipe = async (recipeData) => {
console.log(JSON.stringify(recipeData));
// return
const response = await fetch(`${baseUrl}backend/add-recipe`, {
const response = await fetch(`${baseUrl}/add-recipe`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(recipeData),
@ -45,7 +45,7 @@ export const addRecipe = async (recipeData) => {
export const setDBStars = async (id, stars) => {
console.log(JSON.stringify({ id: id, stars: stars }));
// return
const response = await fetch(`${baseUrl}backend/set-stars`, {
const response = await fetch(`${baseUrl}/set-stars`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id: id, stars: stars }),
@ -58,7 +58,7 @@ export const setDBStars = async (id, stars) => {
export const deleteRecipe = async (id) => {
console.log(id);
// return
const response = await fetch(`${baseUrl}backend/delete-recipe`, {
const response = await fetch(`${baseUrl}/delete-recipe`, {
method: "DELETE",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ id }),