I'm seeking a deeper understanding of working with vueJS.
My current setup
In my Login.vue
component, there is a function logUser()
from UserActions.js
which in turn calls the postRequest()
function from AxiosFacade.js
Additionally, I use a plugin to display Toast information using
createApp(App).use(Toaster).mount('#app')
and trigger the toaster with this.$toast.show(`Default Toast Message`)
What I aim to achieve
I want to be able to call this.$toast.show
from the catch blocks of Axios calls in AxiosFacade.js
For example:
return axios.post(`${serv}/${ressource}`,
{
data: params,
},
{headers: {'Authorization': 'Bearer ' + token}})
.then((response) => response = response.data)
.catch((err) => {
this.$toast.error(err.response.data.message);
throw err.response.data.message
})
However, I am unsure about how to establish connections between .js and .vue files
PS: My next objective is to create my own Toaster.vue
component and control it (showing/hiding) from AxiosFacade.js
. Any advice on this would be appreciated :)
Thank you!