1

I did not encounter problem with fetching, storing, and deleting data using GET, POST, DELETE. It's just updating that I've been stucked for almost an hour.

My question is why Laravel does not get any data? And how should I fix this?


Here is the data I passed from front-end
let formData = new FormData();
formData.append("name", this.teamData.name);
formData.append("image", this.teamData.image);
formData.append("year_joined", this.teamData.year_joined);
formData.append("_method", "PUT");
//more code here..

I am sure that the data was passed

enter image description here

Method I use from server

public function update(Request $request, Team $team)
{
    return response()->json(request()->all());
}

The problem is, it returns none even I passed existing FormData.

Johnny
  • 447
  • 2
  • 13
  • 1
    Please share your `update` route – Christophe Hubert Aug 11 '20 at 04:33
  • @ChristopheHubert `Route::resource('teams', 'TeamController')->except(['create','show','edit']);` I there is no problem with route/sending request as you can see in the screenshot the data-request was successfully sent. – Johnny Aug 11 '20 at 04:47
  • I found the answer. I sent `PUT` in my axios instead of `POST`. this link was helpful https://stackoverflow.com/questions/50691938/patch-and-put-request-does-not-working-with-form-data – Johnny Aug 11 '20 at 04:57

0 Answers0