Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created November 18, 2021 13:16
Show Gist options
  • Select an option

  • Save codecademydev/d1b81ab4d75ec78d26378c438bb1ede3 to your computer and use it in GitHub Desktop.

Select an option

Save codecademydev/d1b81ab4d75ec78d26378c438bb1ede3 to your computer and use it in GitHub Desktop.
Codecademy export
const express = require('express');
const app = express();
const PORT = process.env.PORT || 4001;
const currencies = {
diram: {
countries: ['UAE', 'Morocco'],
},
real: {
countries: ['Brazil'],
},
dinar: {
countries: ['Algeria', 'Bahrain', 'Jordan', 'Kuwait'],
},
vatu: {
countries: ['Vanuatu'],
},
shilling: {
countries: ['Tanzania', 'Uganda', 'Somalia', 'Kenya'],
},
};
app.put('/currencies/:name/countries', (req, res, next) => {
const countries = req.query;
const currencyName = req.params.name;
currencies[currencyName] = countries;
res.send(currencies[currencyName]);
})
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment