Skip to content

Instantly share code, notes, and snippets.

@grant
Last active August 27, 2019 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grant/d7e7241204cb4bb116d50e66331c92c3 to your computer and use it in GitHub Desktop.
Save grant/d7e7241204cb4bb116d50e66331c92c3 to your computer and use it in GitHub Desktop.
Express Routing: Switch (2)
export function getAllUsers(req, res) {
// TODO: Get users from a database
res.send(['Alice', 'Bob']);
}
export function getUser(req, res) {
// TODO: Get user details
res.send({ name: 'Alice', location: 'LAX', });
}
export function getDefault(req, res) { res.status(404).send('Bad URL'); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment