Support the ongoing development of →
posted 1 year ago

Let's simplify building an API in Laravel terms (and I assume a RESTful API).

Create a route:

Route::get('/pokemon', function () {

Return some data:

Route::get('/pokemon', function () {
    return ['Bulbasaur', 'Charmander', 'Squirtle'];

Then, when you hit http://localhost/pokemon in your web browser, you'll see this (in the JSON format):

['Bulbasaur', 'Charmander', 'Squirtle']

This is an API is its simplest form.

Makes sense?

Now let's say someone is trying to build a Pokedex. This person could use your (RESTful) API to display the data it provides.

Still makes sense? Let me know.

— Benjamin from Larabiz (Découvrez les bases du routing)

Last updated 1 year ago.

Sign in to participate in this thread!


Your banner here too?

rey rey Joined 30 Aug 2022


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.