XHR Request with FormData is POSTing an empty array,
By : DaddyDoc
Date : March 29 2020, 07:55 AM
Hope that helps use this code to dispaly file data
|
why In get method i am getting empty fields when posting request in react?
By : helpme please
Date : March 29 2020, 07:55 AM
this one helps. on submit you are calling this.submit function but in your code you declared as handleSubmit(). change the name of submit function from handleSubmit to submit code :
handleSubmit(e){
var self e.preventDefault();
self = this console.log(this.state);
var data = { dataConnectionName:this.state.dataConnectionName, dataConnectionType: this.state.dataConnectionType };
}
// use this function
submit(e){
var self e.preventDefault();
self = this console.log(this.state);
var data = { dataConnectionName:this.state.dataConnectionName, dataConnectionType: this.state.dataConnectionType };
}
|
Axios posting empty request
By : user1417213
Date : March 29 2020, 07:55 AM
it helps some times The issue came from the fact that body-parser wants an x-www-form-urlencoded request, and I wasn't providing one. I've set the header for the axios request to it, and the code looks like this: code :
axios.post( '/register',
{email: email, password: password, username: username, company: company},
{headers: {'Content-Type': 'application/x-www-form-urlencoded'}}).then(response => {
console.log(response.data);
});
|
Request body is empty when posting form-data
By : user2852483
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You will need to parse your form data from express side. For this you will have to use multer or multiparty. Try something like this. refer the documentation as well code :
const multiparty = require('multiparty');
app.post('/user-form-post', (req,res) =>{
let form = new multiparty.Form();
form.parse(req, function(err, fields, files) {
Object.keys(fields).forEach(function(name) {
console.log('got field named ' + name);
});
});
})
|
Posting to backend but request always empty (vue to node)
By : nhuiszoon
Date : March 29 2020, 07:55 AM
should help you out Temporarily comment out the line where you set the headers to application/x-www-form-urlencoded. Then add app.use(bodyParser.json()) to your server.js and see if it works. What's happening is your request object is malformed, which is why the server cannot parse the request correctly.
|