Energy-Price-News-API/energy-prices-api

[FEAT] - Pagination of articles

Closed this issue · 7 comments

What feature would you like to see?

The list of returned articles is getting quite long. It might be time to start thinking about adding pagination to the list.

Possible implementation

Set up as an accepted query parameter with a default setting of unpaginated if not specified to prevent breaking apps already made to consume the data as it is.

We'll need the usual things like:

  • url for next & previous pages
  • current page number
  • total item count
  • total page count
  • items per page

Additional information

No response

hey @MizouziE can I work on this ?

@MuminAhmadKhan absolutely!

I had a look at some packages like pagination and pagination-object which I wouldn't be against implementing OR I'd be more than happy if you wanted to build it from scratch.

Take a look at the packages anyway as they'd make a good guideline at the very least.

Thanks!

As @MizouziE said, I would suggest that you build it from scratch instead of using a library or a pagination library.
I think it's more simple to use lodash slice method

Thanks @MizouziE and @takanome-dev , I will look into the suggestions and update you guys accordingly!

For this url :http://localhost:8000/api/news/?page=2&limit=6
image
For this url :http://localhost:8000/api/news/?page=2
image
Limit is 5 by default.
For this url :For this url :http://localhost:8000/api/news/
image
By default no pagination.
Is this what was expected ?

Yes that's absolutely perfect. You built that already??

Yes I have built it