DavideViolante / socialblade-com-api

Unofficial APIs for socialblade.com website.
MIT License
14 stars 8 forks source link

TypeError: Cannot read property 'map' of null, when retrieving Twitter data for certain profiles #20

Closed veller closed 3 years ago

veller commented 3 years ago

Error

I get an error when trying to hit certain profiles on Twitter such as bilaraujjo. The same error doesn't occur when hitting other profiles such as obama's. The problem seems to happen for smaller profiles. My profile also returns an error.

How to reproduce

Import the lib such as the example in readme file. Change Barack Obama profile for the ones mentioned above.

console.log (await socialblade(http://api.scraperapi.com?api_key=f941895b4d245ae8491266fe2f58bfef&url=<my_key>, 'twitter', 'bilaraujjo'))

Full error log

TypeError: Cannot read property 'map' of null
    at /Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:101:25
    at Array.map (<anonymous>)
    at convertArrayToObject (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:67:17)
    at socialblade (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/index.js:35:34)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async main (/Users/veller/Programming/seguidometro_bbb/socialblade.js:110:22)
Failed once, retrying...
TypeError: Cannot read property 'map' of null
    at /Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:101:25
    at Array.map (<anonymous>)
    at convertArrayToObject (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:67:17)
    at socialblade (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/index.js:35:34)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async main (/Users/veller/Programming/seguidometro_bbb/socialblade.js:110:22)
Failed once, retrying...
TypeError: Cannot read property 'map' of null
    at /Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:101:25
    at Array.map (<anonymous>)
    at convertArrayToObject (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/functions.js:67:17)
    at socialblade (/Users/veller/Programming/seguidometro_bbb/node_modules/socialblade-com-api/index.js:35:34)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async main (/Users/veller/Programming/seguidometro_bbb/socialblade.js:110:22)
Request failed too many times, aborting.
undefined
DavideViolante commented 3 years ago

Hi, thanks for reporting. Could you please test it again with the latest version (2.2.2) and let me know if it works correctly? Thanks.

veller commented 3 years ago

Thanks for such a rapid response.

To be fair the error isn't happening anymore. However I was expecting to see the table array being populated with daily activities for the profiles I mentioned e.g. bilaraujjo

So now if I run...

console.log (await socialblade(http://api.scraperapi.com?api_key=<my_key>&url=, 'twitter', 'bilaraujjo'))

... I don't see the error neither the data.

Any ideas on what might be causing that?

DavideViolante commented 3 years ago

As you can see from the code I get details from the following page: https://socialblade.com/twitter/user/<username>/monthly It seems like the user bilaraujjo has incomplete data for both the table and the charts, for unknown reason related to socialblade.

ps: it's better if you hide your scraperapi personal api_key from your comments to prevent others from using it.