Update the ApiFetcher to have option to get a field or get the JSON.

main
KKlochko 2 years ago
parent 6c13fe7d7d
commit e178d1c8b4

@ -6,7 +6,7 @@ use GuzzleHttp\Client;
class ApiFetcher class ApiFetcher
{ {
public function get($endpoint) { public function get($endpoint, $field = 'items') {
$client = new Client(); $client = new Client();
$baseUrl = config('dotsapi.base_url'); $baseUrl = config('dotsapi.base_url');
@ -31,8 +31,10 @@ class ApiFetcher
); );
$data = json_decode($response->getBody()->getContents(), true); $data = json_decode($response->getBody()->getContents(), true);
$items = $data['items'];
return $items; if($field == '')
return $data;
return $data[$field];
} }
} }

Loading…
Cancel
Save