title: How to make a post request to mongo db atlas using node.js and express.js
body: <p>I am trying to make a simple post request to Mongo Db Atlas using Node.js, Express.js and Mongoose.js. I fill out the form and send the request but it just keeps loading, no erros, nothing. ANyone have any ideas? </p>
  
  <pre><code>//Require assets
  const express = require('express');
  const app = express();
  const mongoose = require('mongoose');
  let port = 3000;
  
  const bodyParser = require('body-parser');
  
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));
  
  const MongoClient = require('mongodb').MongoClient;
  const uri = 'mongodb+srv://michael:&lt;PASSWORD-GOES-HERE&gt;@around-town-vsisv.mongodb.net/admin';
  const client = new MongoClient(uri, { useNewUrlParser: true });
  
  client.connect(err =&gt; {
      const collection = client.db('around_town_db').collection('events');
     // perform actions on the collection object
      client.close();
  });
  
  mongoose.Promise = global.Promise;
  
  var eventSchema = mongoose.Schema({
      eventName: String,
  })
  
  var eventData = mongoose.model('Event', eventSchema);
  
  //Load index page using endpoint
  app.get('/', (req, res) =&gt; {
      res.sendFile(__dirname + '/index.html');
  });
  
  //Post using endpoint
  app.post('/addevent', (req, res) =&gt; {
      var userData = {
         eventName: req.body.eventName 
      }
      new eventData(userData)
      .save()
     .then(res =&gt; {
       res.send('item saved to database');
     })
     .catch(err =&gt; {
       res.status(400).send('unable to save to database');
     });
  });
  
  //Listen on port 3000
  app.listen(port, () =&gt; {
   console.log('Server listening on port ' + port);
  });
  </code></pre>
  
  <p>Below is a simple form for submitting the post request. Any ideas on what I am missing? </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
   &lt;head&gt;
   &lt;title&gt;Add a local event&lt;/title&gt;
   &lt;/head&gt;
  
   &lt;body&gt;
   &lt;div class="app"&gt;
      &lt;h1&gt;Add an event&lt;/h1&gt;
      &lt;form method="post" action="/addevent"&gt;
      &lt;label&gt;Enter event Name&lt;/label&gt;&lt;br&gt;
      &lt;input type="text" name="eventName" placeholder="Enter event name..." required&gt;
      &lt;input type="submit" value="Add Event"&gt;
      &lt;/form&gt;
   &lt;/div&gt;
   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>