I have installed the newest version of laravel which is Laravel 8. Now, I'm making an API and encountered this weird problem. I'm doing the API wayback Laravel 5.6 so it's not new to me.
Problem:
Route::apiResource('/test', UserController::class);
The GET method returns blank when using postman even when I wrapped it in auth:api middleware to check if {"message":"Unauthenticated."} will be shown but it does not. Meaning, even error is not working. But when I changed my route to post, it worked.
Here's my route list:
Here's the POSTMAN response for GET method:
Here's the POSTMAN response for POST method:
Here's the controller:
public function index()
{
return response()->json([
'success' => true,
'data' => ['test' => 'test'],
'message' => 'Success'
], 200);
}
public function store(Request $request)
{
return response()->json([
'success' => true,
'data' => ['test' => 'test'],
'message' => 'Success'
], 200);
}
As you can see they are the same so the postman should returns the same for GET and POST. I already tried route:clear but it doesn't work.
Thank you.


