1

I have a vuejs method which implements axios to send a put/create request over to my laravel api create method passing over some data.

create(data) {
    this.mute = true;
    window.axios.put('/api/showreels/create', {data}).then(({ data }) => {
        this.showreels.push(new Showreel(data));
        this.mute = false;
    }).catch(error => {
            document.write(error.response.data);
    });
},

My api.php is setup with the following resource

//Showreel
Route::resource('/showreels' , 'ShowreelController' , [
 'except' => ['edit', 'show', 'store']
]);

And I have a create method to handle the request and update persist the data. (Which I have added a load of debugging in)

    /**
 * Create a new resource.
 *
 * @return \Illuminate\Http\Response
 */
public function create(Request $request)
{

    $message = 'sdfsdfsdf';
    $message =  $message . $request->heading . 'BALLS';

    \App::abort(500, $message);

    $showreel = new Showreel();
    $showreel->heading = $request->heading;
    $showreel->subheading = $request->subheading;
    $showreel->detail =  $request->heading;
    $showreel->youtubeid =  $request->youtubeid;


    $showreel->heading = "test";
    $showreel->subheading = "test";
    $showreel->detail = "test";
    $showreel->youtubeid = "test";



    $showreel->save();

    return response($showreel->jsonSerialize(), Response::HTTP_CREATED);
}

However laravel is giving me this error.

enter image description here

Not sure why I am getting this error?

1
  • I have figured out that the put request was calling my update method and not the create method. Now I just need to figure out how to create since my api is not allowing a post request. Commented Nov 17, 2018 at 15:03

1 Answer 1

3

Looks like I had the STORE option disabled in my api.php which was closing down the post request option. The post request now takes me through to my store method in laravel.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.