Skip to content
Snippets Groups Projects
Commit 516ef38b authored by Anni Eskelinen's avatar Anni Eskelinen
Browse files

3.12

parent 09fc20cc
No related branches found
No related tags found
No related merge requests found
......@@ -60,7 +60,15 @@ let reminders = [
Reminder
.findById(request.params.id)
.then(reminder => {
if (reminder) {
response.json(formatReminder(reminder))
} else {
response.status(404).end()
}
})
.catch(error => {
console.log(error)
response.status(400).send({error: 'malformatted id'})
})
/*
const id = Number(request.params.id)
......@@ -74,13 +82,25 @@ let reminders = [
}
*/
})
// muistutuksen poisto
app.delete('/api/reminders/:id', (request, response) => {
Reminder
.findByIdAndRemove(request.params.id)
.then(result => {
response.status(204).end()
})
.catch(error => {
response.status(400).send({ error: 'malformatted id' })
})
/*
const id = Number(request.params.id)
reminders = reminders.filter(reminder => reminder.id !== id)
response.status(204).end()
*/
})
/*
// luodaan id käyttämällä Math.random
const generateId = () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment