Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Endpoint 1
app.get('/api', function(req, res){
res.send('Welcome to our API')
})
// Endpoint 2
app.get('/api/users', function(req, res){
res.json(userData);
})
// Endpoint 3
app.get('/api/user/:id', function(req, res){
const id = req.params.id;
const user = userData.find(user => user.id === id);
if (user) {
res.json(user)
}
else {
res.send('No User Found')
}
})
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.