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
pnpm install
pnpm 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();
- Log in or register on CodeSandbox - Sign in
- Return to the
express-guest-list-api-memory-data-store
GitHub repository and addbox
betweengithub
and.com
in the URL (githubbox.com
instead ofgithub.com
) - this creates a synced template on CodeSandbox - Click on "Fork" at the top right of the page - this creates a devbox in your account from the synced template
- Beside "Fork", click "Share", select "Public" from the "Visibility" dropdown and click "Move Devbox" - this allows everybody read access to your devbox
The API can be accessed at the URL in the preview pane on the right (URL ends with csb.app
).