это мой сценарий:
async validate(){
var url = "https://sportmanagementsystemapi.herokuapp.com/api/event/" + localStorage.id;
var bodyFormData = new FormData();
bodyFormData.set("titre", this.create_event.name);
bodyFormData.set("nom_coach", this.create_event.nom_coach);
bodyFormData.set("details", this.create_event.details);
bodyFormData.set("date_debut", this.create_event.start);
bodyFormData.set("date_fin", this.create_event.end);
bodyFormData.set("role", this.create_event.role);
bodyFormData.set("facture_client", this.create_event.facture_client);
bodyFormData.set("facture_coach", this.create_event.facture_coach);
await axios.post(url, bodyFormData, {
headers: {
token: localStorage.token
}
});
var i;
if(this.create_event.nb != 0) {
for(i = 0; i < this.create_event.nb; i++) {
var oldTime = this.create_event.start.split(' ')[1];
var start = new Date(this.create_event.start);
var [date, month, year] = new Date(start.getFullYear(), start.getMonth(), start.getDate()+7).toLocaleDateString().split('/');
this.create_event.start = year + '-' + month + '-' + date + ' ' + oldTime;
var oldTimeend = this.create_event.end.split(' ')[1];
var end = new Date(this.create_event.end);
var [date, month, year] = new Date(end.getFullYear(), end.getMonth(), end.getDate()+7).toLocaleDateString().split('/');
this.create_event.end = year + '-' + month + '-' + date + ' ' + oldTimeend;
bodyFormData.set("titre", this.create_event.name);
bodyFormData.set("nom_coach", this.create_event.nom_coach);
bodyFormData.set("details", this.create_event.details);
bodyFormData.set("date_debut", this.create_event.start);
bodyFormData.set("date_fin", this.create_event.end);
bodyFormData.set("role", this.create_event.role);
bodyFormData.set("facture_client", this.create_event.facture_client);
bodyFormData.set("facture_coach", this.create_event.facture_coach);
await axios.post(url, bodyFormData, {
headers: {
token: localStorage.token
}
});
}
}
this.dialog = false;
window.location.reload();
},