Created
February 11, 2019 18:30
-
-
Save mattmaribojoc/aa11f044a5a64c91e62764726ede4dbc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
app.post('/addTodo', (req, res) => { | |
const collection = client.db('test').collection('todos') | |
var todo = req.body.todo // parse the information from the request's body | |
collection.insertOne({title: todo}, function (err, results) { | |
if (err) { | |
console.log(err) | |
res.send('') | |
return | |
} | |
res.send(results.ops[0]) // returns the document we just inserted | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment