Static GitHub Issues

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

prev: How can i build lodash to vendor with lodash-webpack-plugin & babel-plugin-lodash
next: Add Firebase Custom Server Integration Causing Error

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'
  },
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2471">#c2471</a>)</em></sub></div>