Im using (in the browser):
xmlHttp.open("POST", "/", true); // true for asynchronous xmlHttp.send("data");
on the client side browser.
I’m using (node js):
app.post("/", function (req, res) { console.log("Got a POST request"); console.log(req); });
to get the post data. but it doesn’t matter what I send it doesn’t show up. I don’t wanna have to install some separate “body parser” package to see the data…. I don’t wanna parse it. A post request is used to send data to the server… is the data just not there?
Advertisement
Answer
I don’t wanna have to install some separate “body parser” package to see the data…. I don’t wanna parse it.
Too bad.
Even if you want to process a plain text body then you need to use body parsing middleware to do it.
One of the responsibilities of the middleware is to take the stream of data from the client and store it in memory (assigning it to req.body
) instead of discarding it.
Note that body parsing middleware is installed automatically as a dependency of Express.js itself.