[Vuejs]-Vuex4 state populated with api call is undefined in component

0👍

In setup function you access state or getter with computed :

computed(() => store.state.tenantLocale.timezone)

0👍

You can do like this

import { computed } from 'vue'
import { useStore } from 'vuex'

export default {
  setup () {
    const store = useStore()

    return {
      // access a state in computed function
      timezone: computed(() => store.state.tenantLocale.timezone),

    }
  }
}

Leave a comment