Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mangadex API returning null results for '/chapter' endpoint #51

Closed
MxBlu opened this issue Dec 12, 2021 · 3 comments
Closed

Mangadex API returning null results for '/chapter' endpoint #51

MxBlu opened this issue Dec 12, 2021 · 3 comments

Comments

@MxBlu
Copy link
Contributor

MxBlu commented Dec 12, 2021

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
Copy link
Owner

md-y commented Dec 13, 2021

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
Copy link
Contributor Author

MxBlu commented Dec 13, 2021

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
Copy link
Owner

md-y commented Dec 13, 2021

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

@md-y md-y closed this as completed Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants