md-y/mangadex-full-api

APIRequestError when using Tags with Manga.search

spacehamster opened this issue · 1 comments

When passing a Tag object into a Manga.Search quey, an APIRequestError is raised. The cause appears to be the tag getting encoded as excludedTags[]=[object+Object] in the HTTPS request URI. Using tag.id instead of the tag objects themselves works as expected.

Example:

let tag = await MFA.Manga.getTag('isekai');
let results = await MFA.Manga.search({
    limit: 10,
    title: 'isekai',
    order: { 'followedCount' : 'desc' },
    excludedTags: [tag]
});
for(let manga of results)
{
    console.log(manga.title);
}

Exception:

APIRequestError: [X-Request-ID: 0f53dd3c-2c11-40c5-85ee-609ec6dd3001] Error validating /excludedTags/0: Must be at least 36 characters long (400: validation_exception)
    at IncomingMessage.<anonymous> (c:\Code\Project\node_modules\mangadex-full-api\src\util.js:86:37)
    at IncomingMessage.emit (node:events:525:35)
    at endReadableNT (node:internal/streams/readable:1359:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 2,
  requestId: '0f53dd3c-2c11-40c5-85ee-609ec6dd3001'
}
md-y commented

Fixed