[Vuejs]-Algolia instantsearch pagination doesn't show 2nd page result

2๐Ÿ‘

I think you need to use the paginate method to send the correct page to the frontend.

public function search(Request $request)
{
    $error = ['error' => 'No results found, please try with different keywords.'];

    if($request->has('q')) {
        $movies = Movie::search($request->get('q'))->paginate(20)->all();
        return $movies ? $movies : $error;
    }

    return $error;
}

You can pass the page number explicitly if you need to:

Movie::search($request->get('q'))->paginate(20, 'p', 3)->all();
๐Ÿ‘คJulien Bourdeau

Leave a comment