How do I collect HTML form data when hosting and store it on my MongoDB database?
I am trying to setup a small application to collect form data from users and store it on MongoDB database. I was able to do this on my local server by setting the HTML action attribute to point to my localhost route used for setting up the Express post method which is http://localhost:4000/login. I also connected to the MongoDB database using mongodb://localhost:27017/db and everything works fine. My question is how do I make this work on a hosting platform like Netlify which I am currently using? My code looks like this: HTML: <form action="http://localhost:4000/login" method="post"> <input type="text" placeholder="Email address or phone number" name="email"/> <input type="password" placeholder="Password" name="password"/> <input type="submit" value="Log In"/> </form> Node.js: mongoose.connect('mongodb://localhost:27017/db') app.post('/login', async (req, res) => { const data = res.body response = await Login.create(data) } )