Skip to content
Advertisement

Laravel 7 API pagination is not working after first time

I am trying search functionality through API. I am getting the response with pagination details for the first time but to load more results next_page_url is giving no results

GET http://127.0.0.1:8000/api/search?keyword=cityname&minPrice=0&maxPrice=0&bed=any&propertyType=RESEDENTIAL

I am retuning the results after some very basic filters

JavaScript

Response I am getting is

JavaScript

To load more results I am sending a get request to ‘next_page_url’

GET http://127.0.0.1:8000/api/search?page=2

response is

JavaScript

My API Route: Route::get('/search', 'SearchController@index');

Advertisement

Answer

Finally I am able to solve by doing simple suggestion by a friend.

I use POST method to search with query params as form data

POST http://127.0.0.1:8000/api/search

then I use next page url as same as above (query params as form data)

POST http://127.0.0.1:8000/api/search?page=2

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement