In my Vue application, I am currently receiving a JSON object structured like this:
[
{
"meetingName":"ewq",
"meetingUrl":"",
"meetingPw":"",
"date":"2021-05-30",
"times":[
{
"startTime":"15:30",
"endTime":"16:30"
},
{
"startTime":"17:30",
"endTime":"18:30"
}
]
},
{
"meetingName":"ewq",
"meetingUrl":"",
"meetingPw":"",
"date":"2021-05-31",
"times":[
{
"startTime":"15:30",
"endTime":"16:30"
}
]
}
]
My goal is to have the JSON object structured like this instead:
{
"meetingName":"Test",
"meetingPw":"test22",
"meetingUrl":"localhost",
"meetingTimes":[
{
"date":"15.12.2020",
"times":[{
"startTime":"15:00",
"endTime":"16:00"
}]
},
{
"date":"25.12.2020",
"times":[
{
"startTime":"17:00",
"endTime":"18:00"
},
{
"startTime":"19:00",
"endTime":"2:00"
}
]
}
]
}
Despite trying, I can't seem to modify my code to achieve the desired structure. Can someone please review my code and point out where I might be going wrong?
<script>
import DatePickerComponent from "@/components/DatePickerComponent";
export default {
name: "GenerateMeetingSettings",
data: () => ({
selectedTime: [],
dates: new Date().toISOString().substr(0,10),
datesFinal: [],
meetingSettingUrl: "",
meetingPW: "",
generatedLink: false,
meetingName: "",
dialog: false,
menu: false,
modal: false,
menu2: false,
menu3: false
}),
methods:{
addTimeFields(){
this.selectedTime.push({
startTime:"",
endTime: "",
})
},
saveDateAndTIme(e) {
this.datesFinal.push({
meetingName: this.meetingName,
meetingUrl: this.meetingSettingUrl,
meetingPw: this.meetingPW,
date: this.dates,
times: this.selectedTime
}
)
this.selectedTime = [];
},
generateMeetingLink(){
let meetinId = this.meetingName
console.log(this.meetingName)
this.meetingSettingUrl = "http://localhost:8080/" + meetinId
this.generatedLink = true
console.log(JSON.stringify(this.datesFinal))
}
}
I have included only the script section of my code as that's where the manipulation for the array takes place.