mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-06 18:33:12 +00:00
Test out API requests from frontend to backend
This commit is contained in:
parent
53cbe6e26c
commit
8416549858
5 changed files with 87 additions and 6 deletions
29
front/src/lib/api.js
Normal file
29
front/src/lib/api.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import Items from '%/lib/testData.js';
|
||||
|
||||
export async function getPopularToday() {
|
||||
const res = await fetch("/api/items")
|
||||
const data = res.json()
|
||||
|
||||
if (res.ok) {
|
||||
return data
|
||||
} else {
|
||||
throw new Error("Failed to fetch popular today")
|
||||
}
|
||||
}
|
||||
|
||||
export function getMenuItems() {
|
||||
return [
|
||||
{
|
||||
name: "Main Menu",
|
||||
items: Items,
|
||||
},
|
||||
{
|
||||
name: "Breakfast",
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
name: "Seasonal",
|
||||
items: Items,
|
||||
},
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue