Skip to content

Instantly share code, notes, and snippets.

@lmas3009
Created January 29, 2021 15:25
Show Gist options
  • Save lmas3009/946c97c3792fa39a35ece41d4597e750 to your computer and use it in GitHub Desktop.
Save lmas3009/946c97c3792fa39a35ece41d4597e750 to your computer and use it in GitHub Desktop.
Rest API using MEN (MongoDB,ExpressJs and NodeJs)
app.post("/Cars_add", function (req, res) {
const dbfeed = req.body
try {
Cars.create(dbfeed, (err, data) => {
if (err) {
res.status(500).send(err)
}
else {
res.status(201).send(data)
}
})
} catch (error) {
console.log(error);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment