I've encountered a challenge while trying to save form data in a format where there's the same key but different values separated by commas. While I can successfully submit form data via POST for single "key/value" pairs, I'm struggling with handling "key/multiple(values)" pairs.
Would appreciate any insights or suggestions on this matter.
async handleSubmit(event) {
event.preventDefault();
const token = localStorage.getItem("token");
let url = "https://api/slef_domain/assign_dId/?";
var form = new FormData();
form.append("sourcedomainID", this.state.sourceDomID);
form.append("destInfra", this.state.destInID);
form.append("destdomainID", this.state.destDomID);
form.append("domainRangeId", this.state.domainRanID);
// Need assistance on how to handle multiple values for the same key in the form
// Here we use the FETCH method to POST data and display the response back on Web.
await fetch(url, {
method: "POST",
body: form,
headers: { "Authorization": `Token ${token}` },
"mimeType": "multipart/form-data",
}).then((results) => {
return results
}).then(response => {
console.log("Actual Response: ", response)
if (response.status === 204) {
console.log("Response 204: ", response)
this.setState({ alertMessage: "Success" })
}
else {
console.log("Response no code: ", response)
this.setState({ alertMessage: "Unavailable" })
}
});
}