Data from the browser is sent as follows:
var formData = new FormData(); formData.append("test", "123"); var res = new XMLHttpRequest(); res.open( "post", "/post", true ); res.send(formData); Come to Node.js (express)
app.use(bodyParser.json()); app.use(bodyParser.urlencoded({extended: true})); app.post("/post", function(req, res) { console.log(req.body); res.send(null); }); And there is an empty object {} If you send data from the usual form, then everything is fine. If you send an http post request from an angular one, everything is fine too. From FormData () does not come as if nothing.
I have already tried a lot of things. For example, if you send with such a header
res.setRequestHeader('content-type', 'application/x-www-form-urlencoded'); So in the end something comes up. They even have the necessary data. It is not clear how to decode them
{ '------WebKitFormBoundaryhACdDHCWbVp8Xjtp\r\nContent-Disposition: form-data; name': '"test"\r\n\r\n123\r\n------WebKitFormBoundaryhACdDHCWbVp8Xjtp--\r\n' } Very strange. On the Internet for some reason there is no one with the same problem. Thank you in advance.