Search code examples
laravelpostlaravel-5getroutes

Laravel 5 GET is working but POST method is not working


I am new to Laravel and I am facing a weird issue. In the routes I am calling a function through POST and GET method.

GET returns data but POST doesn't. Here is my simple code:

For POST

Route::post('register', function() {
    echo 'we are here';
});

For GET:

Route::get('register', function() {
    echo 'we are here';
});

Please help. Thank you.


Solution

  • You need to include a CSRF token on every request (except GET).

    https://laravel.com/docs/5.2/routing#csrf-protection