I want to get all values of a property and store it as an array. I have tried this way
data() {
return {
roomList: null
}
},
methods: {
getRooms() {
var that = this
axios.get('http://localhost:3000/roomList')
.then(function(response) {
that.roomList = response.data
})
let roomLists = that.roomList.map(i => i.name) //getting the property values
return roomLists;
},
},
mounted: function () {
this.getRooms()
},
I'm quite sure that I put the map
function in the wrong place. I have tried putting it in the data
but it doesn't work as well. I can't seem to figure out where I should put that function.
If anyone can help me, I would really appreciate it. Thank you.