No problem.
In your Livewire component, after you’ve made the API call I’d then just pull out the pagination data so you can use that to build pagination controls in your view:
class TestComponent extends Component
{
public $search;
public $page;
public $records;
public $nextPageUrl;
public $previousPageUrl;
public function mount()
{
$response = Http::get('https://api.artic.edu/api/v1/artworks/search', [
'q' => $this->search,
'page' => $this->page,
'limit' => 12,
])->json();
$this->records = $response['data'];
$this->previousPageUrl = Arr::get($response, 'pagination.prev_url');
$this->nextPageUrl = Arr::get($response, 'pagination.prev_url');
}
public function render()
{
return view('livewire.test.test-component');
}
}
This will do the API call and then assign the items in the data key to the $records property, and assign the pagination.prev_url to the $previousPageUrl property and pagination.next_url to the $nextPageUrl property if they exist. You can then render some basic pagination controls in your view based on these variables:
<nav aria-label="pagination">
@if($previousPageUrl)
<a href="?page={{ $page-1 }}">Previous</a>
@endif
@if($nextPageUrl)
<a href="?page={{ $page+1 }}">Next</a>
@endif
</nav>