Test out API requests from frontend to backend

This commit is contained in:
Michał Gdula 2024-04-27 17:15:13 +01:00
parent 53cbe6e26c
commit 8416549858
5 changed files with 87 additions and 6 deletions

View file

@ -1,7 +1,14 @@
import Items from '%/lib/testData.js';
export function getPopularToday() {
return Items;
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() {