title: 500 TypeError: Cannot read property 'name' of undefined WHILE transferring data from html form to Node js server?
body: <p>I am trying to send data from html page to NodeJS server .</p>
  
  <p>my html code is :</p>
  
  <pre><code>&lt;body&gt;
  
          &lt;nav&gt;
  &lt;ul&gt;
  &lt;li&gt;
    &lt;a href="#" class="button add"&gt;Add Product&lt;/a&gt;
    &lt;div class="dialog" style="display:none"&gt;
    &lt;div class="title"&gt;Add Product&lt;/div&gt;
    &lt;form action="addevent" method="get"&gt;
      &lt;input id = "name" name="name" type="text" placeholder="Product Name"/&gt;
      &lt;input name="code" type="text" placeholder="Product Code"/&gt;
      &lt;input name="category" type="text" placeholder=" Category"/&gt;
      &lt;input name="brand" type="text" placeholder="Brand"/&gt;
  &lt;input type="submit" value="Ok"/&gt;
    &lt;/form&gt;
  &lt;/div&gt;
  &lt;/li&gt;
  &lt;li class="radio"&gt;
    &lt;a href="#" class="button active"&gt;&lt;/a&gt;
  
    &lt;a href="#" class="button"&gt;&lt;/a&gt;
  
    &lt;a href="#" class="button"&gt;&lt;/a&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  &lt;/div&gt;        
  &lt;/nav&gt;
  &lt;p&gt;&lt;/p&gt;
      &lt;script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'&gt;&lt;/script&gt;
  
          &lt;script src="js/index.js"&gt;&lt;/script&gt;
  
  
  
  
    &lt;/body&gt;
  </code></pre>
  
  <p>and my server code is :</p>
  
  <p><strong>server.js</strong></p>
  
  <pre><code>var express = require("express"),
      app = express(),
      bodyParser = require('body-parser'),
      errorHandler = require('errorhandler'),
      methodOverride = require('method-override'),
      hostname = process.env.HOSTNAME || 'localhost',
      port = parseInt(process.env.PORT, 10) || 4004,
      publicDir = process.argv[2] || __dirname + '/public';
  var exec = require('child_process').exec;
  var fs = require('fs');
  
  //Show homepage
  app.get("/", function (req, res) {
    res.redirect("/index.html");
  });
  app.get("/addevent", function (req, res){
     res.send('You sent the name "' + req.body.name + '".');
  
  });
  
  //Search page
  app.use(methodOverride());
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({
    extended: true
  }));
  app.use(express.static(publicDir));
  app.use(errorHandler({
    dumpExceptions: true,
    showStack: true
  }));
  
  console.log("Server showing %s listening at http://%s:%s", publicDir, hostname, port);
  app.listen(port);
  </code></pre>
  
  <p>but it gives following error when i submit the form from html page !</p>
  
  <blockquote>
  <pre><code>Connect
  500 TypeError: Cannot read property 'name' of undefined
     at app.use.bodyParser.urlencoded.extended (/home/shubham/Music/pricesync/server/server.js:17:45)
     at Layer.handle [as handle_request] (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/layer.js:95:5)
     at next (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/route.js:131:13)
     at Route.dispatch (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/route.js:112:3)
     at Layer.handle [as handle_request] (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/layer.js:95:5)
     at /home/shubham/Music/pricesync/server/node_modules/express/lib/router/index.js:277:22
     at Function.process_params (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/index.js:330:12)
     at next (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/index.js:271:10)
     at expressInit (/home/shubham/Music/pricesync/server/node_modules/express/lib/middleware/init.js:33:5)
     at Layer.handle [as handle_request] (/home/shubham/Music/pricesync/server/node_modules/express/lib/router/layer.js:95:5)
  </code></pre>
  </blockquote>