So client-side-js just send POST with JSON object
$.ajax({
type: 'POST',
url: '/onadd',
data: addJsonObj.toJSON,
success: function(){
console.log("Task added!", data);
}
});
to my nodeJS server.
I see my incoming request on nodeJS server. So how can I parse JSON object from request on my nodeJS server? Need smth like that:
if(request.method == 'POST' && request.url == '/onadd'){
var jsonObj = JSON.parse(request.body); //can't parse JSON here!(
console.log(jsonObj.task);
console.log('hoorayyyy!!!!!!'); //got this!
}