KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why can't I receive plain text sent in a POST request body? The request made from a client browser: var xhr = new XMLHttpRequest(); xhr.open("POST", "/MyRoute/MySubRoute"); xhr.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); xhr.send("hello!"); Using Express with my node server: app.post('/MyRoute/MySubRoute', function(req, res) { console.log("Received:"+require('util').inspect(req.body,{depth:null}); res.send(); }); Logged to the console I get: Received:{} I've tried with text/plain (no charset), with the same result. If I change my content type to application/json and pass a simple JSON string it works fine.
Tags (comma-separated)
Save Edits
Cancel