Closed PwaDesu closed 6 years ago
Do you have the code example that gives the error? Would help a lot 😄
const malScraper = require('mal-scraper');
malScraper.getWatchListFromUser('Paradoxalcorp')
.then(u => {
console.log(u);
})
.catch(err => {
//This is triggered
console.log(err);
});
So I figured this out.
https://myanimelist.net/profile/Paradoxcorp means that the user is Paradoxcorp
and not Paradoxalcorp
.
Actually, the user Paradoxalcorp
does not exist in MAL database therefore it cannot find any user of that name. There is a bug here but it is not what you described, mal-scraper
should reject an error there.
Fixed code for your problem:
const malScraper = require('mal-scraper');
malScraper.getWatchListFromUser('Paradoxcorp')
.then(u =>{
console.log(u);
})
.catch(err => {
//This is triggered
console.log(err);
});
Oh god i wasn't using the right name and i didn't even realised... my deepest apologies...,.
Second issue is a real one tho, im almost sure of that ^^
This issue addresses 2 bugs i ran into with the getWatchListFromUser() method :
First:
TypeError: Cannot read property '0' of undefined at parseString (D:\Felix\chino\indev\node_modules\mal-scraper\src\watchList.js:76:38) at Parser.<anonymous> (D:\Felix\chino\indev\node_modules\xml2js\lib\parser.js:303:18) at emitOne (events.js:115:13) at Parser.emit (events.js:210:7) at SAXParser.onclosetag (D:\Felix\chino\indev\node_modules\xml2js\lib\parser.js:261:26) at emit (D:\Felix\chino\indev\node_modules\sax\lib\sax.js:624:35) at emitNode (D:\Felix\chino\indev\node_modules\sax\lib\sax.js:629:5) at closeTag (D:\Felix\chino\indev\node_modules\sax\lib\sax.js:889:7) at SAXParser.write (D:\Felix\chino\indev\node_modules\sax\lib\sax.js:1436:13) at Parser.exports.Parser.Parser.parseString (D:\Felix\chino\indev\node_modules\xml2js\lib\parser.js:322:31)
Line 76 of the watchList file, when it resolves the promise, it tries reading the first element of mal.myinfo (which i guess is supposed to be an array), however mal.myinfo doesn't seem to be defined for all users.By that i mean that it doesn't work with some users, and work with some others. For reference:
The bug happen with the user Paradoxalcorp (https://myanimelist.net/profile/Paradoxcorp) Works as expected with the user niputi (https://myanimelist.net/profile/niputi)
Second:
Within the stats object that is in the object returned by getWatchListFromUser(), the property name of the property containing the username is undefined instead of username or name (see the screenshot)