I have the following problem:
I want to send my form data to a rest api and the form in my data looks like this:
data(){
return {
form: {
...
selectedCategoriesRoomCount: {
categoryName: '',
roomCount: ''
}
}
}
}
when I make a post request with axios the json data looks like this:
selectedCategoriesRoomCount {
categoryName: "Business Casual",
roomCount: "2"
}
But I need the key value pair to look like this:
selectedCategoriesRoomCount: {
"Business Casual": "2"
},
How can I achieve that? Thank you in advance
>Solution :
Try this:
selectedCategoriesRoomCount['Business Casual'] = 2;