Vuejs beginner here, I have this Reservation System that checks out availability with CheckIn, CheckOut, and RoomCapacity using a datepicker and two number inputs (one for Adult and one for kids) and using axios.get
to get the values. The CheckIn and CheckOut works fine, but the RoomCapacity stays none in the query string params but when console logging, it shows the value.
Here's The console.log and
the query string params
Here's the Vue code:
<b-tab title="Search Rooms" :disabled="step !== 0">
<div class="date">
<p>Pick a date:</p>
<!-- <date-picker v-model="time1" valueType="format" range ></date-picker> -->
<HotelDatePicker
format="DD/MM/YYYY"
@check-in-changed="updateCheckIn($event),searchCheckIn($event)"
@check-out-changed="updateCheckOut($event), searchCheckOut($event)"
></HotelDatePicker>
</div>
<div class="guestCount">
<p>Number of adults:</p>
<InputNumber :max="14" :min="1" v-model="bookForm.AdultCount" size="large"></InputNumber>
<br />
<p>Number of kids:</p>
<InputNumber :max="10" :min="0" v-model="bookForm.KidCount" size="large"></InputNumber>
<br />
</div>
<br/>
<b-button
@click="step = 1; searchRooms(); check(); totalGuest();"
variant="primary"
>Check Available Rooms</b-button>
</b-tab>
The data:
searchForm:{
CheckInDate:'',
CheckOutDate:'',
RoomCapacity:'',
},
The method:
searchRooms(){
axios.get("http://localhost:3000/searchRooms",{
params:{
CheckInDate: this.searchForm.CheckInDate,
CheckOutDate: this.searchForm.CheckOutDate,
RoomCapacity: this.searchForm.RoomCapacity,
}
})
.then((res)=>{
if(res.data[0]){
// no problem
if(res.data[1].length){
//rows retrieved
this.roomList=res.data[1]
this.notice=""
this.err_msg=""
}else{
//no matching row
this.notice="No rooms found"
this.roomList=[]
this.err_msg=""
}
}else{
this.err_msg = res.data[1]
this.roomList=[]
this.notice=""
}
})
.catch((err)=>{
this.err_msgP="AJAX error"
this.PalacioRooms=[]
this.noticeP=""
})
},
totalGuest(){
let totalGuest = this.bookForm.KidCount + this.bookForm.AdultCount;
this.searchForm.RoomCapacity = totalGuest.toString();
},
check(){
console.log(this.searchForm)
},
I tried making the RoomCapacity
to 0 but same problem, it just stays zero.