Note that there are some explanatory texts on larger screens.

plurals
  1. POAccessing parameters from nodeJS/ExpressJS sent from html form by POST Method
    primarykey
    data
    text
    <p>I would like to know the command to access parameters sent through post method from HTML Forms</p> <p>I have tried all these but they print <code>undefined</code> or sends back an <code>error</code> ...</p> <p><b>EDIT 1:</b> Forgot to mention, I have also added this <code>server.use(express.bodyParser());</code></p> <p><b>EDIT 2:</b> </p> <pre><code>var express = require('express'), server = express(), client = require('mysql').createConnection({ host:'localhost', user:'root', password:'password' }); </code></pre> <p>using dbCRUD for rest services in MySQL</p> <pre><code>var dbcrud = require('dbcrud').init(client, 'contacts', model); </code></pre> <p>then I do a </p> <pre><code>server.use(express.bodyParser()); </code></pre> <p>the post functionality is carried out here..</p> <pre><code>server.post('/families',function(req,res){ console.log(req.id); console.log("1: " + req.param.id); console.log("2: " + req.params.id); console.log("3: " + req.param("id")); console.log("4: " + req.params('id')); console.log("5: " + req.params[0]); console.log("6: " + req.body.name); console.log("7: " + req.body.notes); console.log("8: " + req.body.id); //console.log("5: " + req.params[0]); res.send('Hello POST : families'); }); </code></pre> <p>I add the routes here...</p> <pre><code>dbcrud.addRoutes(server); </code></pre> <p>In HTML Form i have specified the id and name attributes for the input tag ...</p> <pre><code>&lt;form method="post" action="http://10.180.218.72:3000/families"&gt; id : &lt;input type="number" id="id" name="id"&gt;&lt;/input&gt; name : &lt;input type="text" id="name" name="name"&gt;&lt;/input&gt; notes : &lt;input type="text" id="notes" name="notes"&gt;&lt;/input&gt; &lt;input type="submit" value = "submit" &gt;&lt;/input&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload