Sep 4, 2021
0
Level 1
how to get data from external api using array request
I need help... I need to extract data from external api in laravel but using a array of data for example: I have an array of users which is
{
"users":["jon", "doe"]
}
then I will call the external api url base on the array data requested and display response also base on the array requested.
//example
//links _of_external_api?usernameusername={users:["jon", "doe"]}"
$response = "";
$data = collect($request['usernames']);
$url = Http::get("links _of_external_api?users=$data");
for ($i = 0; $i < count($data); $i++) {
$response = $response . $url;
return response()->json($response);
}
Please or to participate in this conversation.