Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'simpleText' of undefined #57

Closed
wikanonymous-dev opened this issue Jun 14, 2022 · 4 comments
Closed

TypeError: Cannot read property 'simpleText' of undefined #57

wikanonymous-dev opened this issue Jun 14, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@wikanonymous-dev
Copy link

wikanonymous-dev commented Jun 14, 2022

Describe the bug
Hi there! I got this error on my debugger TypeError: Cannot read property 'simpleText' of undefined from searching some channel.
Channel is hiding the information about subscribers

I think you need add try catch for this function. Thank you

const convertSubs = (channel: any): number => {
    const count = channel.subscriberCountText.simpleText.split(' ').shift();

    // If there's no K, M or B at the end.
    if (!isNaN(+count)) return +count;

    const char = count.slice(-1);
    let slicedCount = Number(count.slice(0, -1));

    switch (char.toLowerCase()) {
        case 'k':
            slicedCount *= 1000;
            break;
        case 'k':
            slicedCount *= 1e6;
            break;
        case 'b':
            slicedCount *= 1e9;
            break;
    }

    return ~~slicedCount;
};

To Reproduce
Steps to reproduce the behavior:

  1. Search query is UCadOPMAkX21lbuA1yj0JfCQ
  2. See error

Expected behavior
It should return the channel's information with subscriberCount is zero or just '-'

Screenshots

Versions:

  • Package: 2.1.14
  • Node: 10.21.0

Additional context
Add any other context about the problem here.

@wikanonymous-dev wikanonymous-dev added the bug Something isn't working label Jun 14, 2022
@DrKain
Copy link
Owner

DrKain commented Jun 14, 2022

Thanks for reporting. Would you mind telling me what query you searched to catch this error?

@wikanonymous-dev
Copy link
Author

Thanks for reporting. Would you mind telling me what query you searched to catch this error?

Im searching for this channel id UCadOPMAkX21lbuA1yj0JfCQ
with the option type is channel

@DrKain DrKain closed this as completed in d3a5c8b Jun 14, 2022
@DrKain
Copy link
Owner

DrKain commented Jun 14, 2022

Should be resolved in 2.1.15. Let me know if you have any other problems. Thanks

@wikanonymous-dev
Copy link
Author

Thanks. It works well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants