mirror of
https://github.com/Fluffy-Bean/TastyBites.git
synced 2025-06-19 08:30:36 +00:00
Add fake API to allow for testing of requests
This commit is contained in:
parent
2686fb904c
commit
782c88d082
7 changed files with 86 additions and 46 deletions
|
@ -1,4 +1,4 @@
|
|||
import Items from '%/lib/testData.js';
|
||||
import Items from '%/lib/test-data.js';
|
||||
|
||||
export async function getPopularToday() {
|
||||
const res = await fetch("/api/items")
|
||||
|
|
30
front/src/lib/test-api.js
Normal file
30
front/src/lib/test-api.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import Items from '%/lib/test-data.js';
|
||||
|
||||
async function fakeDelay(timeout = 1000) {
|
||||
await new Promise(resolve => setTimeout(resolve, timeout));
|
||||
}
|
||||
|
||||
export async function getPopularToday() {
|
||||
const data = Items;
|
||||
await fakeDelay(2000)
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function getMenuItems() {
|
||||
const data = [
|
||||
{
|
||||
name: "Main Menu",
|
||||
items: Items,
|
||||
},
|
||||
{
|
||||
name: "Breakfast",
|
||||
items: [],
|
||||
},
|
||||
{
|
||||
name: "Seasonal",
|
||||
items: Items,
|
||||
},
|
||||
];
|
||||
await fakeDelay(2000)
|
||||
return data;
|
||||
}
|
|
@ -1,53 +1,72 @@
|
|||
// "vegan", "fish", "nut", "spicy", "gluten"
|
||||
|
||||
let Items;
|
||||
export default Items = [
|
||||
const Items = [
|
||||
// soap: {
|
||||
{
|
||||
uuid: "soap",
|
||||
name: "Bar of Soap",
|
||||
price: 69.99,
|
||||
labels: ["vegan", "spicy"],
|
||||
},
|
||||
// sock: {
|
||||
{
|
||||
uuid: "sock",
|
||||
name: "Sock",
|
||||
price: 21,
|
||||
labels: ["vegan", "fish", "nut", "spicy"],
|
||||
},
|
||||
// brick: {
|
||||
{
|
||||
uuid: "brick",
|
||||
name: "Brick",
|
||||
price: 0,
|
||||
labels: ["spicy"],
|
||||
},
|
||||
// toast: {
|
||||
{
|
||||
uuid: "toast",
|
||||
name: "Toast",
|
||||
price: 4382749832743,
|
||||
labels: ["gluten"],
|
||||
},
|
||||
// water: {
|
||||
{
|
||||
uuid: "water",
|
||||
name: "water",
|
||||
price: 1,
|
||||
labels: ["fish"],
|
||||
},
|
||||
// mouldy_bread: {
|
||||
{
|
||||
uuid: "mouldy_bread",
|
||||
name: "half eaten mouldy bread",
|
||||
price: -99,
|
||||
labels: ["nut"],
|
||||
},
|
||||
// gwagwa: {
|
||||
{
|
||||
uuid: "gwagwa",
|
||||
name: "GwaGwa",
|
||||
price: "Priceless",
|
||||
labels: ["nut"],
|
||||
image: "/dab.jpg",
|
||||
},
|
||||
// hogmelon: {
|
||||
{
|
||||
uuid: "hogmelon",
|
||||
name: "Hogermellon",
|
||||
price: "1111",
|
||||
labels: ["fish"],
|
||||
image: "/wathog.jpg",
|
||||
},
|
||||
// bluhog: {
|
||||
{
|
||||
uuid: "bluhog",
|
||||
name: "Blue HOGGGGG",
|
||||
price: "ARUGH",
|
||||
labels: ["nut", "gluten", "spicy"],
|
||||
image: "/sonichog.jpg",
|
||||
},
|
||||
];
|
||||
|
||||
export default Items;
|
Loading…
Add table
Add a link
Reference in a new issue