-
Notifications
You must be signed in to change notification settings - Fork 5
Description
This seems to be a bug in the Ticketmaster API itself, with a complementary bug in the client.
I was running a fetch for a few pages of events, using the max per page, 200 (asking for anything larger, the API gives this error: Query param "size" must be less than 200), and a number of times when requesting the last page, I get this error:
TypeError: Cannot convert undefined or null to object
at Function.keys (<anonymous>)
at new Page (/Users/chrisforrette/Code/ticketmaster-api/dist/node/page.js:5:142)
at /Users/chrisforrette/Code/ticketmaster-api/dist/node/utils/getData.js:8:306
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
On the API side, there seems to be a math issue. In my case, the response.page.totalPages was 4 and response.page.totalElements was 784 (as of writing this) and requesting page 4 triggered the failure. If I adjust my math making size to something that, when multiplied by 4, is less than 784, it works—so setting size to 195 (*4 = 780) works great. The behavior I would expect is for the last page to return the last 184 results, but it seems to not want to return anything but 200.
The bug in the client appears to be triggered in the Page constructor when it's trying to run Object.keys on the _embedded key in the response JSON, which is not present when requesting the last page.
Here's the request I was executing to trigger this error, running on Node 8.4.0:
const util = require('util')
const ticketmaster = require('ticketmaster')
const params = {
sort: 'date,asc',
includeTBA: 'no',
includeTBD: 'no',
includeTest: 'no',
size: 200,
page: 4,
radius: 50,
geoPoint: '9yzgerzgz'
}
ticketmaster('******')
.discovery.v2.event.all(params)
.then(results => console.log(util.inspect(results, { depth: null, colors: true })))
.catch(console.error)I'm happy to pull request a fix, but the root of the bug seems to be on the API side, and anything on the client would be bandaid-ish, but please let me know if a PR would be helpful.
Thank you!