Skip to content

Instantly share code, notes, and snippets.

@grant grant/index.js
Last active Aug 27, 2019

Embed
What would you like to do?
Express Routing: Switch
exports.users = (req, res) => {
// Get the first part of the URL
switch (req.url.split('/')[1]) {
case '': getAllUsers(req, res); break;
case 'user': getUser(req, res); break;
default: getDefault(req, res);
}
res.send(req.url);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.