Home

Issue: 2845

$toast is available in mounted but not in created function after browser refresh

[issue link]

I am getting this error ‘Cannot read property ‘error’ of undefined’ after refreshing page in browser.
It works fine if I navigate to page with nuxt-link.
It also works fine if i use $toasted in mounted function instead of created.

  • nuxt@1.3.0
  • vue@2.5.13

mycomponent.vue

  created() {
    // This does not work
    this.$toast.error('Error')
  },
  mounted() {
    // This works
    this.$toast.error('Error')
  }

nuxt.config.js

modules: [
    '@nuxtjs/toast',
  ],
  toast: {
    position: 'bottom-right'
  },
This question is available on Nuxt.js community (#c2471)