Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3630

how to access REST API in laravel 10?

$
0
0

I'm working on a project using laravel 10 that uses REST API but I'm getting a 404 not found error when I tried to test the url http://localhost/api/v1/continent with GET request in Postman.

this is my routes/api.php:

Route::prefix('v1')->name('v1.')->group(function() {    Route::get('continent', function() {        return 'get all continents';    });});

this is the code in my App/Http/Controllers/Api/V1/ContinentController.php:

<?phpnamespace App\Http\Controllers\Api\V1;use App\Models\Continent;use Illuminate\Http\Request;use App\Http\Controllers\Controller;class ContinentController extends Controller{    /**     * Display a listing of the resource.     */    public function index()    {        $list = Continent::all();        // dd($list);        return response()->json($list);    }}

what am I doing wrong? any help is appreciated.


Viewing all articles
Browse latest Browse all 3630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>