Update the ApiFetcher to have option to get a field or get the JSON.
This commit is contained in:
@@ -6,7 +6,7 @@ use GuzzleHttp\Client;
|
||||
|
||||
class ApiFetcher
|
||||
{
|
||||
public function get($endpoint) {
|
||||
public function get($endpoint, $field = 'items') {
|
||||
$client = new Client();
|
||||
|
||||
$baseUrl = config('dotsapi.base_url');
|
||||
@@ -31,8 +31,10 @@ class ApiFetcher
|
||||
);
|
||||
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
$items = $data['items'];
|
||||
|
||||
return $items;
|
||||
if($field == '')
|
||||
return $data;
|
||||
|
||||
return $data[$field];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user