Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gustav1105's avatar

Accessing Session Flash Message with Axios

I was wondering what other people might be doing in the situation I have,

The web Application that I am writing is posting and getting data to the database with Axios, pointing at my API end-point.

When data is uploaded successfully or with errors I want to display a flash message.

The problem however is that I cannot return redirect with ajax requests. Thus I feel I might ask the opinion of other programmers here, As I use laravel for my back-end.

What would be the best practice, Should I use event-listeners and something like web-sockets to automatically refresh page after a update has been successful. (However I only started reading about this kind of implementation and have no knowledge of it yet). Thus I can use my flash message as I would normally in laravel, because the refresh triggers the session to display in the browser.

Or

Is it possible to access the session flash message (or request the info from the back-end) using Axios, and thus create a reactive footer where my flash will be displayed.(If this is possible how will the code look)

//axios get session flash message from api end-point
//Code examples will be very helpfull

Any advice, comments, best practices, code examples, welcome!

Thanks!

0 likes
1 reply
kenny11's avatar

Do you just want to display a flash message when a post is successful?

If so, why don't you write some login inside then

So in your Vue's data data() { return { success: false } } and make it true to show a message after an update is successful.

Please or to participate in this conversation.