connecting to mongodb with express code example

Example 1: connect mongo to express api

//using mongoose
npm i mongoose

const mongoose = require("mongoose");

mongoose
  .connect(
    "your mongodb URI",
    {
      useNewUrlParser: true,
      useCreateIndex: true,
      useFindAndModify: false,
      useUnifiedTopology: true,
    }
  )
  .then(() => console.log("mongodb connected"))
  .catch((err) => {
    console.err(err.message);
    process.exit(1);
  });

Example 2: expressjs with mongodb

app.post('/quotes', (req, res) => { console.log(req.body) })You should be able to get an object similar to the following in your command line:{name: 'pdp',quotes: 'pdp psr pdp'}