Hi
Complete guess here, but what if you do:-
return response()->json($idsArray);
Instead of returning a view at the end?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Kindly i want to pass multiple array in external api, and get the response
This is what i tried but it return on one array 0 => "7200408497". instead of 12 array
dd($jsonData)
array:4 [▼
"error" => null
"payload" => array:2 [▶]
"count" => 2
"total" => 0
]
dd($idsArray)
array:12 [▼
0 => "7200408497"
1 => "7200408223"
2 => "7291213211"
3 => "7200408373"
4 => "7200408652"
5 => "7291213314"
6 => "7200408397"
7 => "7200408375"
8 => "7200408204"
9 => "7200408437"
10 => "7200408639"
11 => "7200408141"
]
My Controller
public function DeviceStatus(Request $request)
{
$queryinput =$request->deviceNumber;
$idsArray =explode(" ", $queryinput);
dd($idsArray);
// $jsonData = [];
foreach ($idsArray as $key=>$id) {
try {
$response = Http::get('http://http://127.0.0.1:8000/extapi/v12/DeviceData/ByDeviceDataSerial/'.$id.'');
$jsonData = $response->json();
// array_push($jsonData,$response);
} catch (\Exception $exception) {
// toastr()->Error($exception->getMessage());
return back()->withError($exception->getMessage());
}
dd($idsArray);
return view('tracedevice.ectsdevicestatus',compact('jsonData'));
}
What can i do to loop that and get that data
Please or to participate in this conversation.