nuxt-community / legacy-modules

MIT License
1.29k stars 157 forks source link

[toast] how use toast in Vuex? #309

Closed sabutai closed 5 years ago

sabutai commented 5 years ago

I want to fire up toast after I get an Axios response in vuex actions. action for example: deletePage: async (context, payload) => { await axios .delete(blah-blah-blah/Page/${payload}) .then((response) => { if (response.status === 200) { this.$toast.global.deletePage(); context.commit('deletePage', payload); } }) .catch(err => { console.log(err); }) .finally(); } in this case I'm get TypeError: "_this is undefined"

What should I do?

This question is available on Nuxt community (#c167)
ghost commented 5 years ago

This issue as been imported as question since it does not respect modules issue template. Only bug reports and feature requests stays open to reduce maintainers workload. If your issue is not a question, please mention the repo admin or moderator to change its type and it will be re-opened automatically. Your question is available at https://cmty.app/nuxt/modules/issues/c167.