Reputation: 11
Kindly i want to pass multiple array in external api, and get the response
I have tried but it return only one array 0 => "7200408497". instead of all array which i request
dd($idsArray)
array:4 [▼
0 => "408497"
1 => "408223"
2 => "132116"
3 => "408373"
]
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'));
}
I need to get all array as per request
EDITED
Output after add new array in jsonData
array:12 [▼
7200408497 => array:4 [▼
"payload" => array:2 [▼
0 => array:44 [▼
"id" => 4484
"position" => array:2 [▶]
"mDeviceID" => "7200408497"
"slave" => array:2 [▶]
"payload" => ""
"deviceDetails" => array:9 [▶]
"isActivated" => true
"serial" => "7200408497"
"isDeleted" => false
"status" => 0
]
1 => array:44 [▶]
]
"count" => 2
"total" => 0
]
7200408223 => array:4 [▶]
Upvotes: 0
Views: 170