[Vuejs]-Vuex Mapping inside Getters

0👍

I think you can just pass the team number as parameter like this :

teamName: (state) => (teamNumber) => state.teamData[teamNumber].name,
teamAcronym: (state) => (teamNumber) => state.teamData[teamNumber].acronym,

Of course, this might need some check to see if the team exists like :

teamName: (state) => (teamNumber) => state.teamData[teamNumber] ? state.teamData[teamNumber].name : ""

Looking to do a loop that will map over the length of the array and set the value that way

I don’t know if this is what you want but you can return all names from your store using the js map function

Example

teamNames: (state) => state.teamData.map(team => team.name)

Leave a comment