[Vuejs]-Inertia.js not calling onSuccess() on delete route

1๐Ÿ‘

1: set redirect back with message data in the controller.

return redirect()->back()->with([
    'messaage' => 'Installer was successfully deleted',
])

2: HandleInertiaRequests middleware.

public function share(Request $request)
{
    return array_merge(parent::share($request), [
        'flash' => [
            'message' => fn () => $request->session()->get('message'),
        ],
    ]);
}

3: in component.

<template>
{{ $page.props.flash.message }}
</template>

<script setup>
import { usePage } from '@inertiajs/inertia-vue3'

const message = usePage().props.value.flash.message
</script>

docs : https://inertiajs.com/shared-data

๐Ÿ‘คhanafi naufal

Leave a comment