javascript - Sweet alert not showing laravel 8

I'm trying to render a sweet alert UI in my controller action , however It's not showing at all and no error message is thrown.

                <form action="/delete/{{$diary->id}}" method="POST">
                     @csrf
                     @method('DELETE')
                     <button type="submit" class="btn text-danger mx-1">delete</button>
                 </form>

and route is Route::delete('/delete/{id}', [DiaryController::class, 'destroy'])->whereNumber('id'); I'm including sweet-alert script in master layout

    @include('sweetalert::alert')
</body>

and the controller action is

 public function destroy($id = null){
  Alert::error('Are you sure you want to delete ' . $id, 'Error Message');
   return view('diaries'); 
}

I followed the instruction provided on the official website documentation https://realrashid.github.io/sweet-alert/

I would appreciate any help, thanks in advance.

Answer

Solution:

I finally figured the answer in my alert.blade.php I added the script type = javascript

<script type="javascript">
    Swal.fire({!!Session::pull('alert.config')!!}); // not working
</script>

By removing type="javascript" it worked like a charm .

<script>
    Swal.fire({!!Session::pull('alert.config')!!});  // working 
</script>

Source