2 years ago

Vue.js - Issues with notifications using axios & Laravel

Posted 2 years ago by rossuhms

Hi Guys,

I'm writing an application using Laravel and Vue.JS. I'm using axios to submit my forms to Laravel. I have written a notification wrapper in JS which will execute when notify('text');is ran in JS, but also listens for a laravel session called notification for any server side notifications I want to pass.

The problem I am experiencing is when, for example, submitting the log in form (which is a modal), as I am using axios I can't redirect the user to the dashboard using Laravel otherwise it will just return the view in the axios promise. So, the only thing I can do is read the response from Laravel confirming authentication, then redirect the user to the dashboard in JS. When they reach the dashboard I want a notification to display saying 'You've been signed in' or to that effect. Does anyone have any suggestions as to how I will achieve this in JS? As obviously any functions I run currently after redirecting the user won't display on the page.

Hope this all makes sense. If you log out of Laracasts, sign back in, then you are redirected to the homepage and a notification pops up to confirm you have signed in. The login looks like it using Vue so I wonder how @JeffreyWay has managed it...

Thanks for any help in advance!

Please sign in or create an account to participate in this conversation.