Unable to send form data into MongoDB database using Node.js












0















So I've been trying to get the data from my form and input it into my database for ages and it just isn't working. There are no errors and nothing is logging.



This is my HTML code:



<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="UTF-8">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">

<title>Signup for NGOs</title>
</head>
<body>
<form class="mt-4 mr-4 ml-4" id="form" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" aria-describedby="emailHelp" placeholder="Enter name of NGO">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" placeholder="Address">
</div>
<div class="form-group">
<label for="phone">Contact Information</label>
<input type="number" class="form-control" id="phone" placeholder="Contact Number">
</div>
<div class="form-group">
<label for="requirements">Requirements (Seperate by Commas)</label>
<input type="text" class="form-control" id="requirements" placeholder="Requirements">
</div>
<button type="submit" class="btn btn-primary" id="submitButton">Submit</button>
</form>

<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="signup.js"></script>
</body>
</html>


And this is my Node.js code:



var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;

var app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.resolve(__dirname, 'public')));

// I've replaced my original username and password with placeholders
var uri = "mongodb+srv://username:password@helpbook-rlpsi.gcp.mongodb.net/test?retryWrites=true";

var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
app.post('/signup', function (req, res) {
dbConn.then(function(db) {
delete req.body._id; // for safety reasons
dbConn.db("NGOs").collections("partners").insertOne(req.body);
console.log('test');
});
});


I don't know what's going wrong. My data isn't being uploaded to the database and for some reason none of the console.log() statements are being executed.










share|improve this question


















  • 1





    can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

    – Aritra Chakraborty
    Nov 28 '18 at 17:58











  • Nope. I tried both and there was still no change. Nothing is getting printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17
















0















So I've been trying to get the data from my form and input it into my database for ages and it just isn't working. There are no errors and nothing is logging.



This is my HTML code:



<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="UTF-8">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">

<title>Signup for NGOs</title>
</head>
<body>
<form class="mt-4 mr-4 ml-4" id="form" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" aria-describedby="emailHelp" placeholder="Enter name of NGO">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" placeholder="Address">
</div>
<div class="form-group">
<label for="phone">Contact Information</label>
<input type="number" class="form-control" id="phone" placeholder="Contact Number">
</div>
<div class="form-group">
<label for="requirements">Requirements (Seperate by Commas)</label>
<input type="text" class="form-control" id="requirements" placeholder="Requirements">
</div>
<button type="submit" class="btn btn-primary" id="submitButton">Submit</button>
</form>

<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="signup.js"></script>
</body>
</html>


And this is my Node.js code:



var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;

var app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.resolve(__dirname, 'public')));

// I've replaced my original username and password with placeholders
var uri = "mongodb+srv://username:password@helpbook-rlpsi.gcp.mongodb.net/test?retryWrites=true";

var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
app.post('/signup', function (req, res) {
dbConn.then(function(db) {
delete req.body._id; // for safety reasons
dbConn.db("NGOs").collections("partners").insertOne(req.body);
console.log('test');
});
});


I don't know what's going wrong. My data isn't being uploaded to the database and for some reason none of the console.log() statements are being executed.










share|improve this question


















  • 1





    can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

    – Aritra Chakraborty
    Nov 28 '18 at 17:58











  • Nope. I tried both and there was still no change. Nothing is getting printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17














0












0








0








So I've been trying to get the data from my form and input it into my database for ages and it just isn't working. There are no errors and nothing is logging.



This is my HTML code:



<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="UTF-8">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">

<title>Signup for NGOs</title>
</head>
<body>
<form class="mt-4 mr-4 ml-4" id="form" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" aria-describedby="emailHelp" placeholder="Enter name of NGO">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" placeholder="Address">
</div>
<div class="form-group">
<label for="phone">Contact Information</label>
<input type="number" class="form-control" id="phone" placeholder="Contact Number">
</div>
<div class="form-group">
<label for="requirements">Requirements (Seperate by Commas)</label>
<input type="text" class="form-control" id="requirements" placeholder="Requirements">
</div>
<button type="submit" class="btn btn-primary" id="submitButton">Submit</button>
</form>

<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="signup.js"></script>
</body>
</html>


And this is my Node.js code:



var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;

var app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.resolve(__dirname, 'public')));

// I've replaced my original username and password with placeholders
var uri = "mongodb+srv://username:password@helpbook-rlpsi.gcp.mongodb.net/test?retryWrites=true";

var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
app.post('/signup', function (req, res) {
dbConn.then(function(db) {
delete req.body._id; // for safety reasons
dbConn.db("NGOs").collections("partners").insertOne(req.body);
console.log('test');
});
});


I don't know what's going wrong. My data isn't being uploaded to the database and for some reason none of the console.log() statements are being executed.










share|improve this question














So I've been trying to get the data from my form and input it into my database for ages and it just isn't working. There are no errors and nothing is logging.



This is my HTML code:



<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta charset="UTF-8">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">

<title>Signup for NGOs</title>
</head>
<body>
<form class="mt-4 mr-4 ml-4" id="form" method="post">
<div class="form-group">
<label for="name">Name</label>
<input type="name" class="form-control" id="name" aria-describedby="emailHelp" placeholder="Enter name of NGO">
</div>
<div class="form-group">
<label for="address">Address</label>
<input type="text" class="form-control" id="address" placeholder="Address">
</div>
<div class="form-group">
<label for="phone">Contact Information</label>
<input type="number" class="form-control" id="phone" placeholder="Contact Number">
</div>
<div class="form-group">
<label for="requirements">Requirements (Seperate by Commas)</label>
<input type="text" class="form-control" id="requirements" placeholder="Requirements">
</div>
<button type="submit" class="btn btn-primary" id="submitButton">Submit</button>
</form>

<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script type="text/javascript" src="signup.js"></script>
</body>
</html>


And this is my Node.js code:



var express = require('express');
var path = require('path');
var bodyParser = require('body-parser');
var mongodb = require('mongodb');
var MongoClient = mongodb.MongoClient;

var app = express();

app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.resolve(__dirname, 'public')));

// I've replaced my original username and password with placeholders
var uri = "mongodb+srv://username:password@helpbook-rlpsi.gcp.mongodb.net/test?retryWrites=true";

var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
app.post('/signup', function (req, res) {
dbConn.then(function(db) {
delete req.body._id; // for safety reasons
dbConn.db("NGOs").collections("partners").insertOne(req.body);
console.log('test');
});
});


I don't know what's going wrong. My data isn't being uploaded to the database and for some reason none of the console.log() statements are being executed.







javascript node.js html5 mongodb bootstrap-4






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 28 '18 at 17:48









Ankit SanghiAnkit Sanghi

111




111








  • 1





    can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

    – Aritra Chakraborty
    Nov 28 '18 at 17:58











  • Nope. I tried both and there was still no change. Nothing is getting printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17














  • 1





    can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

    – Aritra Chakraborty
    Nov 28 '18 at 17:58











  • Nope. I tried both and there was still no change. Nothing is getting printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17








1




1





can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

– Aritra Chakraborty
Nov 28 '18 at 17:58





can you console log before dbConn.then and check if req.body exists? if not maybe use enctype="application/x-www-form-urlencoded" in your form

– Aritra Chakraborty
Nov 28 '18 at 17:58













Nope. I tried both and there was still no change. Nothing is getting printed.

– Ankit Sanghi
Nov 28 '18 at 19:17





Nope. I tried both and there was still no change. Nothing is getting printed.

– Ankit Sanghi
Nov 28 '18 at 19:17












2 Answers
2






active

oldest

votes


















0














The promise probably resolves before the signup handler is called.



Try the following:



var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
dbConn.then(function(client) {
app.post('/signup', function (req, res) {
delete req.body._id; // for safety reasons
client.db("NGOs").collections("partners").insertOne(req.body);
console.log('test');
});
})
.catch(function(err){
console.log(err)
});





share|improve this answer


























  • I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

    – Ankit Sanghi
    Nov 28 '18 at 18:20











  • New hypothesis, changed my answer.

    – Dennis Ruiter
    Nov 28 '18 at 18:40











  • Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17











  • You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

    – Dennis Ruiter
    Nov 28 '18 at 19:23



















0














Looking at your question specifically, you are not using any action in your form.



<form class="mt-4 mr-4 ml-4" id="form" method="post" action="/signup">
...
</form>


So it is not getting posted to your route. (That's why I specifically asked if console logging before the dbconn is working or not)






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53525299%2funable-to-send-form-data-into-mongodb-database-using-node-js%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The promise probably resolves before the signup handler is called.



    Try the following:



    var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
    dbConn.then(function(client) {
    app.post('/signup', function (req, res) {
    delete req.body._id; // for safety reasons
    client.db("NGOs").collections("partners").insertOne(req.body);
    console.log('test');
    });
    })
    .catch(function(err){
    console.log(err)
    });





    share|improve this answer


























    • I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

      – Ankit Sanghi
      Nov 28 '18 at 18:20











    • New hypothesis, changed my answer.

      – Dennis Ruiter
      Nov 28 '18 at 18:40











    • Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

      – Ankit Sanghi
      Nov 28 '18 at 19:17











    • You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

      – Dennis Ruiter
      Nov 28 '18 at 19:23
















    0














    The promise probably resolves before the signup handler is called.



    Try the following:



    var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
    dbConn.then(function(client) {
    app.post('/signup', function (req, res) {
    delete req.body._id; // for safety reasons
    client.db("NGOs").collections("partners").insertOne(req.body);
    console.log('test');
    });
    })
    .catch(function(err){
    console.log(err)
    });





    share|improve this answer


























    • I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

      – Ankit Sanghi
      Nov 28 '18 at 18:20











    • New hypothesis, changed my answer.

      – Dennis Ruiter
      Nov 28 '18 at 18:40











    • Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

      – Ankit Sanghi
      Nov 28 '18 at 19:17











    • You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

      – Dennis Ruiter
      Nov 28 '18 at 19:23














    0












    0








    0







    The promise probably resolves before the signup handler is called.



    Try the following:



    var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
    dbConn.then(function(client) {
    app.post('/signup', function (req, res) {
    delete req.body._id; // for safety reasons
    client.db("NGOs").collections("partners").insertOne(req.body);
    console.log('test');
    });
    })
    .catch(function(err){
    console.log(err)
    });





    share|improve this answer















    The promise probably resolves before the signup handler is called.



    Try the following:



    var dbConn = MongoClient.connect(uri, { useNewUrlParser: true });
    dbConn.then(function(client) {
    app.post('/signup', function (req, res) {
    delete req.body._id; // for safety reasons
    client.db("NGOs").collections("partners").insertOne(req.body);
    console.log('test');
    });
    })
    .catch(function(err){
    console.log(err)
    });






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 28 '18 at 18:39

























    answered Nov 28 '18 at 18:09









    Dennis RuiterDennis Ruiter

    18528




    18528













    • I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

      – Ankit Sanghi
      Nov 28 '18 at 18:20











    • New hypothesis, changed my answer.

      – Dennis Ruiter
      Nov 28 '18 at 18:40











    • Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

      – Ankit Sanghi
      Nov 28 '18 at 19:17











    • You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

      – Dennis Ruiter
      Nov 28 '18 at 19:23



















    • I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

      – Ankit Sanghi
      Nov 28 '18 at 18:20











    • New hypothesis, changed my answer.

      – Dennis Ruiter
      Nov 28 '18 at 18:40











    • Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

      – Ankit Sanghi
      Nov 28 '18 at 19:17











    • You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

      – Dennis Ruiter
      Nov 28 '18 at 19:23

















    I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

    – Ankit Sanghi
    Nov 28 '18 at 18:20





    I tried this and my terminal still doesn't print anything. It's just stuck at node signup.js. After that nothing happens. I changed req.body to {name: "john"} just to see if that makes a difference but it doesn't.

    – Ankit Sanghi
    Nov 28 '18 at 18:20













    New hypothesis, changed my answer.

    – Dennis Ruiter
    Nov 28 '18 at 18:40





    New hypothesis, changed my answer.

    – Dennis Ruiter
    Nov 28 '18 at 18:40













    Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17





    Tried this. Nothing got printed. I even tried to print out req.body but nothing got printed.

    – Ankit Sanghi
    Nov 28 '18 at 19:17













    You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

    – Dennis Ruiter
    Nov 28 '18 at 19:23





    You're sure the form is actually submitting? I see no action property defined on your form. Try adding action="/signup" to your form in the HTML

    – Dennis Ruiter
    Nov 28 '18 at 19:23













    0














    Looking at your question specifically, you are not using any action in your form.



    <form class="mt-4 mr-4 ml-4" id="form" method="post" action="/signup">
    ...
    </form>


    So it is not getting posted to your route. (That's why I specifically asked if console logging before the dbconn is working or not)






    share|improve this answer




























      0














      Looking at your question specifically, you are not using any action in your form.



      <form class="mt-4 mr-4 ml-4" id="form" method="post" action="/signup">
      ...
      </form>


      So it is not getting posted to your route. (That's why I specifically asked if console logging before the dbconn is working or not)






      share|improve this answer


























        0












        0








        0







        Looking at your question specifically, you are not using any action in your form.



        <form class="mt-4 mr-4 ml-4" id="form" method="post" action="/signup">
        ...
        </form>


        So it is not getting posted to your route. (That's why I specifically asked if console logging before the dbconn is working or not)






        share|improve this answer













        Looking at your question specifically, you are not using any action in your form.



        <form class="mt-4 mr-4 ml-4" id="form" method="post" action="/signup">
        ...
        </form>


        So it is not getting posted to your route. (That's why I specifically asked if console logging before the dbconn is working or not)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 19:24









        Aritra ChakrabortyAritra Chakraborty

        2,43811015




        2,43811015






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53525299%2funable-to-send-form-data-into-mongodb-database-using-node-js%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Lallio

            Unable to find Lightning Node

            Futebolista