skip to Main Content

I’m having some problems with this message" The POST method is not supported for this route. Supported methods: GET, HEAD.". I’m building a laravel + vue post app, but I’m not being able to make it work, I don’t know if I’m missing something. This is how my template (in short) looks like:

<div>
    <form action="/post/create" method="POST">
</div>

My routes (just have 1):

Route::get('/post/create', [AppHttpControllersPostController::class, 'create']);

How, can I show the added tickets in the same view, it’s needed to add another route or change the get route to post?, I’m a bit new and I’m very very lost, haha.

I’m using a vue template, not a blade

3

Answers


  1. Chosen as BEST ANSWER

    FINALLY GOT the solution /o/, It was a problem with the csrf token in vue, I have placed the meta csrf in my root blade, and added the hidden input with the csrf and is working everything. Now I just need to show the form post info in idk, in the console, a json, or in the same page. That's a new fight but, well, I have made a great progress /o/


  2. You have to define post method if you using method="POST"

    <div>
        <form action="/tickets/create" method="POST">
    </div>
    
    Route::post('/tickets/create', [AppHttpControllersTicketController::class, 'create']);
    
    Login or Signup to reply.
  3. Just change

    Route::post('/tickets/create', [AppHttpControllersTicketController::class, 'create']);
    

    to

    Route::match(['get', 'post'],'/tickets/create', [AppHttpControllersTicketController::class, 'create']);
    

    This is because, you are using same route for both requests. [loading the form into DOM and posting the form] .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search