I have a server as following:
app.post('/', function(req, res, next) {
console.log(req);
res.json({ message: 'pppppppppppppssssssssssssss ' });
});
The request is sent from a client as:
$.ajax({
type: "POST",
url: self.serverURI,
data: JSON.stringify({ "a": "128", "b": "7" }),
dataType: 'json',
success: function (result) {
console.log(result);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
}
});
so far the connection fine.
My problem is in the server:
console.log(req);
where I want to read the data I sent. How can I read { "a": "128", "b": "7" }
from req
?