Skip to content

Commit

Permalink
Update README.md (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav Shestakov committed Nov 5, 2019
1 parent 0c1026b commit f772c5e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,18 @@ Some of the responses can be long, so multiple requests might be needed to fetch
/** @var array|\Vikingmaster\TampereJourneysApiSdk\Dto\Line[] $entries */
$entries = [];

$fetch = true;
$startIndex = 0;
$fetch = true;

while ($fetch) {
try {
$response = $request->setStartIndex($startIndex)->send();
$entries = array_merge($entries, $response->getLines());
} catch (\Exception $e) {
//Handle exception / resend the request
break;
}

$startIndex = $response->getPaging()->getPageSize();
$fetch = $response->getPaging()->hasMoreData();

$entries = array_merge($entries, $response->getLines());
$startIndex = $response->getPaging()->getPageSize();
}
```

0 comments on commit f772c5e

Please sign in to comment.