Maher Mahouachi Maher Mahouachi - 1 year ago 111
JSON Question

Send JSON data from express to html NodeJS

Hello all i'm new with node so here my use case i want to post data to my express app and show it on a html page is that possible with nodeJs ?

Here my code'/', function(req, res){
res.sendFile(__dirname + '/views/index.html', {data: req.body});

Answer Source

There are many tutorials showing how to do that. I would recommend first you understand how HTTP protocol works (The message structure : Then go dive into node and exchange data through requests and responses. I'd recommend body-parser to arrange the data format between the two sides. Also read the express documentation. Hope it helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download