mardi 10 mai 2022

how to call one api to another api in laravel using wamp server?

in Web.php

Route::get('/apiforsales', [LeadController::class, 'apiforsales']); //this working fine.

Route::get('/apicheck', [LeadController::class,'apicheck123']);

LeadController.php

public function apiforsales(Request $req)
{
 $results = DB::select( DB::raw(" select id,name,implement,lead_type,number,district,state FROM comman_datas where state = '$req->state' and district= '$req->district' and status = '0'  "));   
 return $results;
}

public function apicheck123(Request $req)
{
    $response = Http::get("http://127.0.0.1:8000/apiforsales?state=".$req->state."&district=".$req->district);
    $jsondata= $response->getBody();
    $data =json_decode($jsondata, true);
    return $data;
}

In postman calling a api

http://127.0.0.1:8000/apiforsales?state=Karnataka&district=Bengaluru ..///working fine.

http://127.0.0.1:8000/apicheck?state=Karnataka&district=Bengaluru ..///it will loading to much time not giving a exact cause of



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire