I am making a JSON POST request using XMLHttpRequest, however Express appears to wrap the received JSON in an additional object, how can I prevent this ?
This is the client sending the JSON data:
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://mydev.puremfg.net/",true);
// This header MUST be present for POST requests.
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Accept", "application/json, text/javascript");
var jarr = {"hxx":1};
xhr.send(JSON.stringify({"hxx":1}));
And this is Nodejs / Express middleware:
app.use(function(req, res, next){
fn.console.log(req.body);
})
This is the output:
{ '{"hxx":1}': '' }
via crankshaft
No comments:
Post a Comment