Get Data From Api

  Make first the simplest API.

1. Create Controller Command 

php artisan make:controller ApiController

2. Now Create the Method.

function getdata()
    {
        return ["name"=>"Aqib", "email"=> "aqib123@gamil.com", "address"=>"Pakistan"];
    }

3.Go the routes
Select Api.php

Generate the Route for controller

Route::get("getData", [ApiController::class, 'getdata']);

4. Now go the Postman
Insert the server link
http://127.0.0.1:8000/api/getData


OutPut:





Comments

Popular posts from this blog

Get API with Parameter

get data with API