zyrouge / node-genius-lyrics

Simple lyrics fetcher that uses Genius. Also has official API implementations.
https://genius-lyrics.js.org
MIT License
61 stars 12 forks source link

TypeError: Cannot read properties of undefined (reading 'hits') #36

Closed warior456 closed 1 year ago

warior456 commented 1 year ago
at SongsClient.<anonymous> (H:\discordbot\mrdia-main\node_modules\genius-lyrics\dist\songs\client.js:43:42)
at Generator.next (<anonymous>)
at fulfilled (H:\discordbot\mrdia-main\node_modules\genius-lyrics\dist\songs\client.js:5:58)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
warior456 commented 1 year ago

am i doing something wrong or what?

zyrouge commented 1 year ago

Is this still relevant? If so, please reopen this.

MeridianGH commented 1 year ago

This is actually still relevant, I'm getting this error when using (await Genius.songs.search(title))[0].

zyrouge commented 1 year ago

This is actually still relevant, I'm getting this error when using (await Genius.songs.search(title))[0].

Could you send the whole code and the steps to reproduce this error?

MeridianGH commented 1 year ago

Sure, this is my code without the unneccessary parts:

const Genius = new genius.Client(geniusClientToken)
try {
    const song = (await Genius.songs.search(title))[0]
    const lyrics = await song.lyrics()
    // Process lyrics here
} catch {
    // Send error here
}

geniusClientToken is a string containing my key. title is a valid string that contains the artist name and song title.

However, I was just testing a bit, and this apparently works fine without a key. My key could possibly be invalid, but didn't earlier versions warn you about that?

zyrouge commented 1 year ago

Could you give the value of title so that I'll check if that occurs. The tests seems to pass just fine. I'll check if invalid key causes that.

zyrouge commented 1 year ago

~Could you give the value of title so that I'll check if that occurs. The tests seems to pass just fine.~ I'll check if invalid key causes that.

Seems like I couldn't reproduce this issue. Could you give the title used in that code?

MeridianGH commented 1 year ago

I had the error occur with every title I entered. Turns out the issue was indeed an invalid key though, weirdly enough.

zyrouge commented 1 year ago

API related errors are now handled.