kugatsu765 / vueNotification

Notification plugin for VuesJS
https://codesandbox.io/s/github/kugatsu765/vueNotificationSample2/tree/master/
MIT License
51 stars 9 forks source link

Can we use thus notification from vuex store #33

Closed Vidhyanandcs closed 3 years ago

Vidhyanandcs commented 3 years ago

I have an action which is triggered if an api request throws an error. i would like to take this error message and display them to user from the action. Does such a functionallity exist.

kugatsu765 commented 3 years ago

Hello,

Yes you can achieve this by exporting your vue instance.

export default new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");

then import from any js file and use it.

import vueInstance from "@/main";
[....]
 vueInstance.$notification.error("Produits introuvable");
[...]

I use this method to centralise my error notification from axios configuration and not on each call.

I hope that it helped you.