skip to Main Content

I write two api. One get function and one post function.

Also, I try

public function one(Request $request){
dd("test"); }

public function two(){
dd("test");
}

Always two is working but one does not working. I use http://127.0.0.1:8000.

And my api.php like

Route::post('/one', [AppHttpControllersTestController::class, 'one']);
Route::get('/two', [AppHttpControllersTestController::class, 'two']);

One always return 404 not found. How can I access this service?

2

Answers


  1. the code looks correct.

    Could you please let me know your web server (e.g. Apache/Nginx)?
    Have you activated the rewrite module?

    Alternatively, if you are using Laravel and starting the server with php artisan serve, you should restart it after editing or changing the code.

    or like @fuadps said "are you sure you are access /one by POST request?"

    Login or Signup to reply.
  2. Try clearing the cache of routes.

    php artisan route:clear
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search