md-y/mangadex-full-api

Mangadex API returning null results for '/chapter' endpoint

Closed this issue · 3 comments

MxBlu commented

The Mangadex API has been returning 'null' results when calling Chapter.search(), which causes a TypeError (Cannot read property 'id' of null) in the Chapter constructor.

Exception has occurred: TypeError: Cannot read property 'id' of null
  at new Chapter (mangadex-full-api\src\structure\chapter.js:30:32)
    at mangadex-full-api\src\util.js:211:28
    at Array.map (<anonymous>)
    at Object.apiCastedRequest (mangadex-full-api\src\util.js:211:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at main (/src/sandbox.ts:48:19)

Reproduction is hazy since its a particular set of chapters, but just opening an issue in case we can improve robustness on the package level anyway:

  const results = await Chapter.search({
    limit: 100,
    order: {updatedAt: 'desc'},
    translatedLanguage: [ 'en' ]
  });

image

md-y commented

What is this "particular set of chapters"?

I assume the problem is that the conditional that checks the MD API data is ignoring the null response since it's not falsy, but I can't examine why it's happening without more info.

MxBlu commented

Sadly I couldn't find more info on what those particular chapters were in order to have a concrete reproduction, but I can assist in immitating a similar return result from apiSearchRequest()

new Chapter({ data: null });

I think your guess is spot on - I didn't understand your intention with that line so I didn't try and fix it but switching the check to == null or whatever flavour of test you prefer should fix it.

md-y commented

Alright then I'll probably just change the check to a falsy check for undefined and null in the next version.