how to send only the input to the backend. At this stage, three input boxes have been written, and only two of them may be entered in actual use, but now because they are all written to death, the contents of three boxes will be sent every time, even if they are empty. I don"t know how to send selectively, that is, only get the json with input value.
my data section:
testData:{
"name" :"test",
"mylists":[
{
"user_ids":"",
"group":""
},
{
"user_ids":"",
"group":""
},
{
"user_ids":"",
"group":""
}
]
}
submit Code:
submit(event){
event.preventDefault();
let formData = new FormData();
let testData = JSON.stringify(this.testData);
formData.append("testData", testData);
axios.post("/", formData
,config
....
for example, enter only the first two, but get:
{
"name" :"test",
"mylists":[
{
"user_ids":"1",
"group":"1"
},
{
"user_ids":"1",
"group":"1"
},
{
"user_ids":"",
"group":""
}
]
}
in this case, how can the third row with no value not be displayed?