problem description
the data is submitted through post, then parsed by node, and inserted into the collection using MongoDB.
how does the front end encode the data and then parse it correctly through nodejs?
the environmental background of the problems and what methods you have tried
uses axios to make post requests. At first, it uses JSON.stringify () in the front end, but it doesn"t work. Nodejs parses it like this:
let data = [];
//this.tableData ==>
this.tableData.forEach((item,i) => {
data[i] = Qs.stringify(item);
});
// let data = Qs.stringify(this.tableData[0]);
console.log(data);
axios({
url:"http://localhost:3000/settle_post",
method:"post",
data:data,
transformRequest: [function(data){
return data;
}],
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
})
because I just learned node for not two days, some things are not clear, Baidu still has no results after all kinds of methods, so I can only ask for help from all the bigwigs! Because the younger brother"s knowledge is relatively weak, if you need to provide anything else, please remind me in the comments. Thank you
ps: (currently I"ve come up with a wasteful way to loop the data, and then make an post request for each piece of data--)