Demers94
10 months ago
39
2
Vue

Displaying Paginator links in Javascript

Posted 10 months ago by Demers94

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!

Please sign in or create an account to participate in this conversation.