twlite / youtube-sr

A dead-simple youtube metadata scraper
https://npmjs.com/package/youtube-sr
MIT License
113 stars 16 forks source link

TypeError: fetch is not a function #35

Closed eugabrielsilva closed 2 years ago

eugabrielsilva commented 3 years ago

Throwing error with release v4.1.8 running in NodeJS v14.18.0.

(node:816) UnhandledPromiseRejectionWarning: TypeError: fetch is not a function
    at <project_location>\node_modules\youtube-sr\dist\Util.js:82:13
    at new Promise (<anonymous>)
    at Function.Util.getHTML (<project_location>\node_modules\youtube-sr\dist\Util.js:81:16)
    at Function.<anonymous> (<project_location>\node_modules\youtube-sr\dist\main.js:94:51)
    at step (<project_location>\node_modules\youtube-sr\dist\main.js:44:23)
    at Object.next (<project_location>\node_modules\youtube-sr\dist\main.js:25:53)
    at <project_location>\node_modules\youtube-sr\dist\main.js:19:71
    at new Promise (<anonymous>)
    at __awaiter (<project_location>\node_modules\youtube-sr\dist\main.js:15:12)
    at Function.YouTube.search (<project_location>\node_modules\youtube-sr\dist\main.js:81:16)

Code:

const youtube = require('youtube-sr').default;

youtube.search('test', {limit: 1}).then(data => {
    console.log(data);
});
twlite commented 3 years ago

@eugabrielsilva hey, can you use the older versionbof the package until next update?

twlite commented 2 years ago

forgot to update here but this issue should be fixed https://github.com/DevSnowflake/youtube-sr/releases/tag/v4.1.9