Amazon Product Advertising API Returns Incorrect Pagination / Results

I am working on an application that returns products from Amazon:

client.itemSearch({ 
      condition: 'New',
      keywords: decodeURI(req.query.q),
      merchantId: 'Amazon',
      itemPage: page,
      responseGroup: 'ItemAttributes,Offers,Images' + ',ShippingCharges'
    }, (err, results, response) => {
       // work on results / response
    })

... returns the following answers:

enter image description here

The problem is that the API is right when the page is set to 2, 3, etc. The values ​​are as follows:

  • On page 1: 65 total, 7 pages
  • On page 2: 56 total, 6 pages
  • On page 3: 45 total, 5 pages
  • On page 4: 38 total, 4 pages
  • On page 5: ERROR (whole answer undefined)

It looks like this API is just broken.

I need to know how many pages to display pagination on an external interface. How to do it?

+4
source share
1 answer

Reading through the Amazon API I see:

TotalPages Total number of pages in the response. Each page can return up to ten items. , const pages = Math.ceil(1.4)(TotalResults/10)

, , "". , , , , - .

0

Source: https://habr.com/ru/post/1694063/


All Articles