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
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?"
Try clearing the cache of routes.