I have ajax code in below , i want to read data which is i am sending using ajax i want to read data in server side.
$.ajax({
type: 'POST',
data: {hurl: "test data"},
contentType: 'application/json',
url: 'http://localhost:5000/hmap',
success: function(data) {
// console.log('success');
// console.log(JSON.stringify(data));
console.log(data);
}
});
});
below is my server side node js code
var hmapdata = [];
app.post('/hmap', function(req, res) {
console.log(req.body);
MongoClient.connect(url, function(err, db) {
if (err)
throw err;
db.collection("heatmap").find().toArray(function(err, result) {
if (err)
throw err;
hmapdata = result;
db.close();
});
});
setTimeout(function() {
res.send(hmapdata);
}, 1000);
});