md-y/mangadex-full-api

One of the examples throws an error

Closed this issue · 3 comments

When using the following code from the readme (with working user and password):

const api = require("mangadex-full-api");

api.agent.login("a_User", "password123", false).then(() => {
    var manga = new api.Manga();
    manga.fillByQuery("Ancient Magus Bride").then((manga) => {
        console.log(`${manga.title} by ${manga.authors.join(", ")}`);
    });
});

I get the following error :

internal/errors.js:254 Uncaught (in promise) TypeError [ERR_INVALID_ARG_TYPE]: The "listener" argument must be of type function. Received an instance of Object
at checkListener (events.js:108)
at ClientRequest.once (events.js:430)
at new ClientRequest (_http_client.js:194)
at request (https.js:314)
at Object.get (https.js:318)
at *project path*\node_modules\mangadex-full-api\src\util.js:29
at new Promise (<anonymous>)
at Object.getHTTPS (*project path*\node_modules\mangadex-full-api\src\util.js:11)
at *project path*\node_modules\mangadex-full-api\src\util.js:87
at new Promise (<anonymous>)

This could be a problem on my end as I am not very experienced with js/node.js(v12.18.2) however when I put a console.log just above var manga = new api.Manga(); with api.agent as parameter I can see that there is a session id.
To give a bit more context, I am using Electron as well.

md-y commented

I can't seem to replicate the issue on any version of node using the standalone project. Judging by how there is a session id, the error most likely is originating from the manga search function. However, because I can't seem to replicate the issue, I'm going to assume the issue is with electron or another part of your project and close the issue.

Although, are any of the other examples producing an error?

Thanks for checking, I tried it on a simple node project as well just to make sure and it seems to work. I have tested it on electron as well and it seems to work when calling it form the main script, but not from the BrowserWindow.

This is probably still on my end however I cannot figure out why. The other scripts that are added to the page are jquery, bootstrap and popper.js (which has to do with bootstrap as far as I know) and on my script the example above is the only piece of code written, so it could be something related to electron. To be extra sure I'll try it on a fresh electron project and see if anything changes.

Regarding your question, no, I have not tried all the other examples, only the group one, and it behaves the same as the manga.fillByQuery.

So this library won't work in the frontend of an app (meaning it can't be bundled in a React PWA, or in a React Native app for example, so this will only work in a backend node environment), please add that to the README @md-y.

I got the same error trying to create and instance of the Home class and filling it, from what I'm reading it's because of the export syntax (module.exports = ...)