JiriChara / vue-gravatar

A dead-simple gravatar component for VueJS
MIT License
113 stars 15 forks source link

Setting email from vuex-rest-api #4

Closed ghenry closed 6 years ago

ghenry commented 6 years ago

Hi, I'm setting the email prop as a computed property from vuex like so:

      <v-gravatar 
           class="rounded-circle my-auto d-none d-lg-inline-block"
           v-bind:email="email"
           v-bind:size="34"
           default-img="https://portal.surevoip.co.uk/assets/surevoip-icon-white-80x80.png"
           title="Your Avatar from https://www.gravatar.com" alt="Your Gravatar image"/>

and

  computed: {
    email () {
      return this.$store.state.whoami.whoami.email[0]
    },

On the first load of this component the vuex state hasn't been set so I get:

TypeError: this.$store.state.whoami.whoami.email is undefined
Stack trace:

as the axios promise within vuex-rest-api has not completed yet. I thought computed waits until all state has settled? Any tips? Once the promise has completed it's all set OK.

Thanks.

ghenry commented 6 years ago

It's just a variable, so test it as such. Thanks. Closing.