Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

nafeeur10's avatar

API data is not loading in Laravel 8

I am using Laravel 8. With it I am using Laravel Modules. Link: https://github.com/nWidart/laravel-modules

I have installed Laravel 8 basic Auth System with Jetstream - Inertia - Sanctum

I have made a Route but I can't access the data. When I am hitting/testing the url it's redirect me to the dashboard page.

I got this from php artisan route:list

Method
GET|HEAD 

URL:
api/category                   

Name:
category.index                  

Controller:
Admin\Category\Http\Controllers\CategoryController@index          

Middleware:
App\Http\Middleware\Authenticate:sanctum

My API:

Route::middleware('auth:sanctum')->group(function () {
    Route::apiResource('category', 'CategoryController');
});

Category Controller:

public function index()
    {
        return response()->json([
           'category' => 1 
        ]);
    }

Giving 302 Found Error!

0 likes
1 reply
fylzero's avatar

@nafeeur10 So you know 300 level html response codes are not errors. 400 are client errors and 500 is server errors. A 302 is a redirect message. You'll have to hunt down what you are being redirected to and why to troubleshoot this.

1 like

Please or to participate in this conversation.