Last active
August 27, 2019 17:04
-
-
Save grant/8df1a01017d2d3f0fc788bed10784df4 to your computer and use it in GitHub Desktop.
Express Routing: Switch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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