Skip to main content
fixed typo in code (reponse != response)
Source Link
Pat J
  • 12.3k
  • 2
  • 28
  • 36

You could try something like:

$url = 'https://oc.com/api/v1/employees/?page=1';
$data = array();
while ( $url ) {
    $response = $this->request( $url );
    $data = array_merge( $data, $response->data );
    // if this is not the last page, get the next page URL
    if ( $response->paginator->current_page != $response->paginator->last_page ) {
        $url = $reponse$response->paginator->next_page;
    } else {$url = false;}
}
return $data;

You could try something like:

$url = 'https://oc.com/api/v1/employees/?page=1';
$data = array();
while ( $url ) {
    $response = $this->request( $url );
    $data = array_merge( $data, $response->data );
    // if this is not the last page, get the next page URL
    if ( $response->paginator->current_page != $response->paginator->last_page ) {
        $url = $reponse->paginator->next_page;
    } else {$url = false;}
}
return $data;

You could try something like:

$url = 'https://oc.com/api/v1/employees/?page=1';
$data = array();
while ( $url ) {
    $response = $this->request( $url );
    $data = array_merge( $data, $response->data );
    // if this is not the last page, get the next page URL
    if ( $response->paginator->current_page != $response->paginator->last_page ) {
        $url = $response->paginator->next_page;
    } else {$url = false;}
}
return $data;
Source Link
majick
  • 5.1k
  • 2
  • 18
  • 30

You could try something like:

$url = 'https://oc.com/api/v1/employees/?page=1';
$data = array();
while ( $url ) {
    $response = $this->request( $url );
    $data = array_merge( $data, $response->data );
    // if this is not the last page, get the next page URL
    if ( $response->paginator->current_page != $response->paginator->last_page ) {
        $url = $reponse->paginator->next_page;
    } else {$url = false;}
}
return $data;