How to use:

Soupabase API can be used with any front end project where you need some real-pseudo data supplied in a JSON format. Each soup object has at least one of each data type to aid in prototyping and teaching

Try out the examples below:

Fetch all soups (GET)

fetch('https://cloud-app.soupabase.workers.dev/soup') .then(res => res.json()) .then(json => console.log(json))

Fetch all soups with a limit parameter (GET)

fetch('https://cloud-app.soupabase.workers.dev/soup?limit=2') .then(res => res.json()) .then(json => console.log(json))

Fetch soup by Id (GET)

fetch('https://cloud-app.soupabase.workers.dev/soup/1') .then(res => res.json()) .then(json => console.log(json))

Create a Soup (POST)

fetch('https://cloud-app.soupabase.workers.dev/soup', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ name: "Chocolate Soup", ingredients: ["Chocolate", "Milk", "Sugar"], price: 2.50, hot: true, description: "Chocolate soup is a made up soup for children", imgUrl: "www.newsoupbucket.com/chocolatesoup", origin: {year: 2024, by: "Samantha Suleke", source: "Gains & Gains"}, category: "vegetarian", }) }) .then(res => res.json()) .then(json => console.log(json))

Update a Soup (PATCH)

fetch('https://cloud-app.soupabase.workers.dev/soup/1', { method: 'PATCH', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ "id": "1", "name": "Tomato Soup", "price": 2.5, "ingredients": ["Tomatoes","Salt","Pepper"], "hot": true, "description": "A delicious tomato soup.", "imgUrl": "http://example.com/tomato-soup.jpg", "origin": {"year":1857,"by":"Eliza Leslie","source":"New Cookery Book"}, "category": "vegan", "nullValue": null }) }) .then(res => res.json()) .then(json => console.log(json))

Update a Soup (PUT)

fetch('https://cloud-app.soupabase.workers.dev/soup/1', { method: 'PUT', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ "id": "1", "name": "Tomato Soup", "price": 2.5, "ingredients": ["Tomatoes","Salt","Pepper"], "hot": true, "description": "A delicious tomato soup.", "imgUrl": "http://example.com/tomato-soup.jpg", "origin": {"year":1857,"by":"Eliza Leslie","source":"New Cookery Book"}, "category": "vegan", "nullValue": null }) }) .then(res => res.json()) .then(json => console.log(json))

Delete a Soup (DELETE)

fetch('https://cloud-app.soupabase.workers.dev/soup/1', { method: 'DELETE', }) .then(res => res.json()) .then(json => console.log(json))