Looking to extract all values of a specific property and save them as an array. I attempted the following method:
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) //extracting property values
return roomLists;
},
},
mounted: function () {
this.getRooms()
},
I suspect I may have misplaced the map
function. I tried placing it inside the data
section but encountered issues. I'm struggling to determine the appropriate location for this function.
Any guidance or assistance would be greatly appreciated. Thank you.