A simple, naïve, in-memory RESTful guest list API in Express.
git clone https://github.com/upleveled/express-guest-list-api-memory-data-store.git
cd express-guest-list-api-memory-data-store
yarn
yarn start
const baseUrl = 'http://localhost:4000';
const response = await fetch(`${baseUrl}/guests`);
const allGuests = await response.json();
const response = await fetch(`${baseUrl}/guests/:id`);
const guest = await response.json();
const response = await fetch(`${baseUrl}/guests`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ firstName: 'Karl', lastName: 'Horky' }),
});
const createdGuest = await response.json();
const response = await fetch(`${baseUrl}/guests/1`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ attending: true }),
});
const updatedGuest = await response.json();
const response = await fetch(`${baseUrl}/guests/1`, { method: 'DELETE' });
const deletedGuest = await response.json();
Create a Heroku account at Heroku - Sign up, and then click on this button:
This will set up a new application on your Heroku account using this repo as a template.