aknorw / discojs

Easiest way to use the Discogs API in Javascript/Typescript :musical_note:
https://aknorw.github.io/discojs
MIT License
63 stars 9 forks source link

Support pagination for the searchDatabase endpoint #23

Closed MileanCo closed 4 years ago

MileanCo commented 4 years ago

I noticed the pagination parameters are ignored: "page" and "per_page". You can see in the code here it's not accepting those params and instead silently setting the pagination params to nothing.

https://github.com/aknorw/discojs/blob/ed89e400ea21aa95722ed666fd6a954656a5474a/src/database/search.js#L26

The discogs documentation says this endpoint also accepts pagination. This should be an easy fix :)

MileanCo commented 4 years ago

I was able to fix this by doing the following. It wasnt very clear from the documentation.

 let search_options = {
    'type' : 'release',
    'genre': genre,
  };
  const paginationOpt = {
    'page': 0, 
    'perPage':100,
  };

  let results = await client.searchDatabase(search_options, paginationOpt);