mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-02 00:13:15 +00:00
Clean up test API
This commit is contained in:
parent
0943c99749
commit
18b22e7928
3 changed files with 33 additions and 81 deletions
|
@ -1,36 +1,16 @@
|
|||
import { type Item, type JSONResponse } from "./types";
|
||||
import TestData from "./test-data";
|
||||
|
||||
const API_URL = "http://127.0.0.1:8080";
|
||||
|
||||
export async function getPopularToday(): Promise<Item[]> {
|
||||
const response = await fetch(`${API_URL}/api/items`);
|
||||
const { data, error }: JSONResponse = await response.json();
|
||||
const {data, error}: JSONResponse = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
if (data?.item) {
|
||||
return data?.item;
|
||||
} else {
|
||||
return Promise.reject(new Error("Failed to fetch popular today"));
|
||||
}
|
||||
} else {
|
||||
return Promise.reject(error);
|
||||
throw new Error("Failed to fetch popular today");
|
||||
}
|
||||
}
|
||||
|
||||
export function getMenuItems() {
|
||||
return [
|
||||
{
|
||||
name: "Main Menu",
|
||||
items: TestData,
|
||||
},
|
||||
{
|
||||
name: "Breakfast",
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
name: "Seasonal",
|
||||
items: TestData,
|
||||
},
|
||||
];
|
||||
throw new Error(error);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue