How can I organize my data effectively when dealing with computed properties that have different values?
computed: {
totalCoin() {
const state = this.$store.state.ApiState.totalCoin
let val
if (state === 0) {
val = 0
} else if (state === null) {
val = undefined
} else {
val = state
}
return val
},
totalGem() {
const state = this.$store.state.ApiState.totalGem
let val
if (state === 0) {
val = 0
} else if (state === null) {
val = undefined
} else {
val = state
}
return val
}
repeatedly...
}
Note: All result values will be returned from VueX to a component using computed properties
getToken() {
return this.$store.state.userToken
}
Is there a more readable way of organizing this code for better clarity?