Reputation: 1168
I am currently redirecting from a store route back to my index route with a flash message like this:
public function store(StoreMemberRequest $request)
{
$this->authorize('create', Member::class);
RegisterNewMember::run($request);
return redirect()->route('admin.members.index')->with('success', 'Member successfully created');
}
Normally this flash message shows me a notification on my frontend. I have this bit of code in my HandleInertiaRequests middleware which shares the flash data:
public function share(Request $request)
{
return array_merge(parent::share($request), [
'auth' => [
'user' => $request->user(),
],
'flash' => fn () => [
'success' => session('success'),
'error' => session('error'),
],
]);
}
However, when I redirect back to my admin.members.index
route the flash message is not shown. The only difference between the pages where it works and where it doesn't work is that I see that two requests are being canceled in the console:
More detailed information about the request (the response couldn't be loaded because no data was found):
What could be the cause of the notification not showing? It does show on all other pages where the requests doesn't get canceled. The two canceled requests are literally the only differences that I could find. If someone needs any more detailed information than I would be happy to provide that.
Versions:
Upvotes: 1
Views: 1470
Reputation: 1168
Seems like I had some code which checked for parameters in the url on pageload. When some parameters were set the page would reload. This caused the first request to be canceled. Adding an extra check to this function solved my problem. If anyone else has the same problem, check if anywhere in your code is made a new request.
Upvotes: 0