I used FormData API to add the post data for the request.
Following is an example of how to do so:
let formData = new FormData();
formData.append("customer_procedure_ids", 1);
formData.append("customer_procedure_ids", 2);
Then simply add this to your data parameter in AXIOS.
await axios({
data: formData,
})...;
This will append the data you want to post to the server.
Reference: https://developer.mozilla.org/en-US/docs/Web/API/FormData/FormData
PS: The data you are currently sending goes as JSON. To send it as a Post request you will need FromData API.
This is what I was looking for First, create FormData
then loop through the array and assign an index to the key and add the value as the second arg
const formData = new FormData();
Array.from(this.selected).forEach((element, index) =>
formData.append(`customer_procedure_ids[${index}]`, element)
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.