Skip to content
Advertisement

What is the cause of this route-related error in my Laravel 8 application?

I am working on a Laravel application that requires user registration and login.

Alter registration, the users have the possibility to replace the default avatar image with a picture of their choice.

They should also be able to delete this picture and revert to the default avatar (default.png). For this purpose I did the following:

In routes/web.php I have the necessary routes:

JavaScript

In ControllersDashboardUserProfileController.php I have:

JavaScript

In the view I have this delete button:

JavaScript

The method is executed via AJAX:

JavaScript

The problem

For a reason I was unable to figure out, whenever I click the delete button, I get this error in the browser:

JavaScript

What am I doing wrong?

Advertisement

Answer

You have define your route as post method

JavaScript

In ajax you passing as

JavaScript

Updated

As i see your code ,you are trying to delete loggedin user avatar .So

JavaScript

Change route as

JavaScript

In Ajax

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement