md-y/mangadex-full-api

Chapter.id gets overwritten with undefined

Closed this issue · 2 comments

mftb0 commented

In src/structure/manga.js on ln 85 the constructor for Chapter gets called with the key to a Chapter. The constructor inherited from APIObject gets used, and everything is fine, but then on ln 86 chapter.parse() is called and passed an actual Chapter object, since Mangadex has set the key to the id in their JSON, and there is no actual id property on the chapter, id gets overwritten with undefined. I fixed it in my copy by adding a check like:

if(data.id) this.id = data.id;

...there may be better fixes. Also my project is in Typescript so that may cause some difference I'm unaware of or something (I just auto-generated types for mangadex-full-api).

Thanks! This project is cool.

md-y commented

Thanks for notifying me! The problem is just like you said.

I added the id key to the manga.chapter element before parsing to fix it for version 1.4.0

mftb0 commented

Awesome! Glad it helped.