Tag Archives: node.js tutorial for beginners

Get POST data In Express.js โ€“ Node.js


Get POST data In Express.js โ€“ Node.js: If you are using the Express.Js for Node.js you can get the post query strings ie. post parameters. Express.js is basically high class, high performance web development which is used for node.js. Here we are going to explain how to get the Post parameters passed from a Form using post method.


Get POST data In Express.js โ€“ Node.js

The html & Javascript Part are as below โ€“

Html Part โ€“

Suppose we have following form with the three input fields as below. We are going to post these values using this form.

Get POST data In Express.js โ€“ Node.js:

Javascript Part-

Here is javascript part in which we will get all the three fields posted using the form โ€“

Get POST data In Express.js โ€“ Node.js:

app.use(express.bodyParser());
app.post('/', function(request, response){
    console.log(request.body.customer.name);
    console.log(request.body.customer.email);
	console.log(request.body.customer.phone);
});

Thus you can access any field posted from the Form.

Get Current Date time in Node.js


Get Current Date time in Node.js : You can retrive the current date time in Node.js using Date object. Here in this tutorial we are going to explain how to get current date time in Node.js


Get Current Date time in Node.js

Use the following syntax for getting the current date time โ€“

Get Current Date time in Node.js:

var currdatetime = new Date();
console.log(currdatetime);

The above syntax will give the current date time.

For the newer browsers you can also use the following method quickly-

Node.js Syntax to Get Current Date time:

var currtime = Date.now();
console.log(currdatetime);

The above syntax will also give the current date time in milliseconds.