raulInsto
raulInsto

Reputation: 95

Laravel: Missing Argument error on a POST

I keep getting the error "Missing argument 1 for App\Http\Controllers\Users::deleteMobileAssets()" . I am making a call from my frontend with Vue. When I check the headers, it seems correct but I'm not sure what is causing the error. I've tried wrapping imageType in brackets too: {imageType: imageType} but still same error.

deleteImage(imageType) {
    axios.post('/delete-mobile-assets', imageType);
}

 public function deleteMobileAssets($imageType)
{

}

Upvotes: 0

Views: 51

Answers (1)

Aslam H
Aslam H

Reputation: 1801

POST data is included in the body of the request that way you are getting Missing argument 1. Try this

deleteImage(imageType) {
    axios.post('/delete-mobile-assets', {imageType:imageType});
}

public function deleteMobileAssets(Request $request)
{
  $request->imageType
}

Or if you want to implement DELETE method. have a look Delete Method in Axios, Laravel and VueJS

Upvotes: 1

Related Questions