Demers94's avatar

Displaying Paginator links in Javascript

I'm making an AJAX call to my back-end to retrieve some resources. I want the results to be paginated because there are too many.

Is there a way to send the Pagination's HTML to the front-end via AJAX, so that I can display the page selection menu in my template?

Here's the code I'm using to retrieve the results :

$applications = Application::paginate();

        return [
            'results' => $applications->items(),
            'html' => $applications->links(),  
        ];

And here is my Javascript :

axios.get('/admin/applications/api').then(response => {
                    this.html = response.data.html;
                    this.applications = response.data.results;
                });

I can get the results just fine, but the HTML part is just an empty object.

Is what I'm trying to achieve possible at all?

Thanks!

0 likes
2 replies

Please or to participate in this conversation.