0

i have using ejs engine to get and post method.When i use http://localhost:8080/signup, i will get a sigup form where i can input my values. The problem is after submitting the form,i am unable console the value of "req.body". Help me?

app.post('/signup',urlencodedParser,function(req,res){
    //console.log(req)
    var names = req.body;
    console.log(names);
    res.end("sigup submitted");
});
app.get('/signup', function(req, res) {///////////signup ejs loading
    res.render('signup')
});
<form id="signupForm" enctype="multipart/form-data" method="post" action="">
      <div class="container">
    <h1>Sign Up</h1>
    <p>Please fill in this form to create an account.</p>
    <hr>
     <label for="name"><b>Company Name</b></label>
    <input type="text" placeholder="Company Name" name="name" required>

    <label for="email"><b>Email</b></label>
    <input type="text" placeholder="Enter Email" name="email" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" required>

    <label for="psw-repeat"><b>Repeat Password</b></label>
    <input type="password" placeholder="Repeat Password" name="psw-repeat" required>

    <label for="psw-repeat"><b>Address</b></label>
    <input type="text" placeholder="Address" name="address" required>


    <label>
      <input type="checkbox" checked="checked" name="remember" style="margin-bottom:15px"> Remember me
    </label>

    <p>By creating an account you agree to our <a href="#" style="color:dodgerblue">Terms & Privacy</a>.</p>

    <div class="clearfix">
      <button type="button" class="cancelbtn">Cancel</button>
      <button type="submit" class="signupbtn">Sign Up</button>
    </div>
  </div>
</form>

sachin murali
  • 469
  • 2
  • 7
  • 22

1 Answers1

0

Express does come with some body parsers, but if you are using multipart/form-data then answer would be https://github.com/expressjs/multer not

You can even read that https://www.npmjs.com/package/body-parser (aka body-parser) also do not read multipart/form-data as they can be complicated and should be used only when files are sent.

Seti
  • 2,169
  • 16
  • 26