1
0

Video 91: Resource Reading Endpoints: Part I

This commit is contained in:
JayWll 2020-02-23 15:23:38 -07:00
parent f550158865
commit ff4ec82ef5

View File

@ -18,6 +18,28 @@ app.post('/users', (req, res) => {
}) })
}) })
app.get('/users', (req, res) => {
User.find({}).then((users) => {
res.send(users)
}).catch((e) => {
res.status(500).send()
})
})
app.get('/users/:id', (req, res) => {
const _id = req.params.id
User.findById(_id).then((user) => {
if (!user) {
return res.status(404).send()
}
res.send(user)
}).catch((e) => {
res.status(500).send()
})
})
app.post('/tasks', (req, res) => { app.post('/tasks', (req, res) => {
const task = new Task(req.body) const task = new Task(req.body)