I have a form that is functioning properly and inserting data correctly. However, if the user clicks the submit button multiple times, the data gets inserted multiple times. To prevent this, I want to redirect the user to another page and display a success or error message. Currently, I am using Axios to handle the form submission. Below, I have included the Axios code with a then response and catch error, but I am struggling to display these messages in the HTML:
reserve() {
// this.form.post('../api/comment')
axios.post('../api/reserve',{
property_id:1,
reserve_start:this.date,
reserve_end:this.date2,
}).then(response => {
self.message = 'Data has been successfully entered'
})
.catch(error => {
self.message = 'Error: Data could not be entered'
})
Here is the markup for my form:
<form @submit.prevent="reserve()" id="myForm" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed">