Froedrick's avatar

Software design question reg pagination and external api

The Movie DB database has a route to get the movies in a list. It returns 20 items at a time and the user has the option to include a query string designating the page number

https://www.themoviedb.org/list/8434?page=2

My routes look like this

Route::get('/list/{id}', 'MoviesController@list')->name('movies.list');
Route::get('/list/{id}/{page}', 'MoviesController@list')->name('movies.list');

and in my controller

public function list($id, $page = 1)
    {
        $list = Http::withToken(config('services.tmdb.token'))
            ->get('https://api.themoviedb.org/4/list/'.$id.'?page='.$page)
            ->json();

        ddd($list);
    }

How would you paginate this and would it be easier to have a Load More button at the bottom to append to the list of movies in the same page without having to reload a page? (The Movie DB does handle it that way)

0 likes
3 replies
DemarionFitzpatrick's avatar

Hope everything went well for you! I'm having a similar problem and am still looking for a solution.

Please or to participate in this conversation.