Empty req.body receiving text/plain POST request to node.js
Summarising the above comments which answer the question:
- The client's XMLHttpRequest is correct
- On the server side, Express uses connect's bodyParser which by default only supports the following content types:
- application/json
- application/x-www-form-urlencoded
- multipart/form-data
- Because the content-type of text/plain is not implemented by Express, there is no method to wait for the body to be received before calling the app/post route.
- The solution is to add the text/plain content type to Express as described here
Add
app.use(express.text())
You can read more about it here