Skip to content

Instantly share code, notes, and snippets.

View cjmccaskill's full-sized avatar

CJ McCaskill cjmccaskill

View GitHub Profile
@cjmccaskill
cjmccaskill / expressmongo.js
Created August 13, 2021 23:24 — forked from AlexMercedCoder/expressmongo.js
Ways of Writing Express/MongoDB routes (Callback, Async/Await, .then)
///////////////////////////////////////
// Writing the Index Route all three ways
// (Callback,.then, async/await)
///////////////////////////////////////
// callback
app.get("/dogs", (req, res) => {
Dog.find({}, (err, data) =>
err ? res.status(400).json(err) : res.json(data)
);