Skip to main content
2 de 2
se añadieron 14 caracteres en el cuerpo
Alfabravo
  • 9.9k
  • 5
  • 24
  • 32

The GET method is not supported for this route. Supported methods: POST

No me funcionan las rutas en laravel

web.php

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
// Rutas de prueba
Route::get('/', function () {
    return view('welcome');
});




// Rutas del controlador de usuario
Route::post('/api/register', 'UserController@register');
Route::post('/api/login', 'UserController@login');

UserController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
  public function pruebas(Request $request)
  {
    return "acción de pruebas de  USER-CONTROLLER";
  }

  public function register(Request $request)
  {
      // $data = array(
      //   'status' =>'error',
      //   'code' => 404,
      //   'message' =>'El usuario no se ha creado'
      // );
      //
      // return response()->json($data, $data['code']);
  }

  public function login(Request $request)
  {
      return "accion de login de usuarios";
  }
}

el error:

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
The GET method is not supported for this route. Supported methods: POST. 

al ejecutar la ruta localhost/proyecto/api/register me da este error, en el kernel he desactivado \App\Http\Middleware\VerifyCsrfToken::class,