SocialBlade / socialblade-js

Library for Social Blade's Official API in JavaScript (TypeScript)
https://socialblade.com/api
BSD 3-Clause "New" or "Revised" License
41 stars 7 forks source link

ReferenceError: fetch is not defined #8

Closed freezegr closed 3 years ago

freezegr commented 3 years ago
(node:4508) UnhandledPromiseRejectionWarning: ReferenceError: fetch is not defined
    at Matrix.<anonymous> (C:\Users\xaris\desktop\follow\node_modules\socialblade\dist\matrix.js:29:13)
    at Generator.next (<anonymous>)
    at C:\Users\xaris\desktop\follow-sub\node_modules\socialblade\dist\matrix.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\xaris\desktop\follow\node_modules\socialblade\dist\matrix.js:4:12)
    at Matrix.request (C:\Users\xaris\desktop\follow\node_modules\socialblade\dist\matrix.js:25:16)
    at Matrix.<anonymous> (C:\Users\xaris\desktop\follow\node_modules\socialblade\dist\matrix.js:38:31)
    at Generator.next (<anonymous>)
    at C:\Users\xaris\desktop\follow\node_modules\socialblade\dist\matrix.js:8:71
    at new Promise (<anonymous>)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:4508) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4508) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

how to fix it

timcole commented 3 years ago

Node does not have fetch built-in like your browser, there are many different options you can use though. As stated in the README.

Library does not force any fetch polyfills, If you don't already have a fetch polyfill we recommend using isomorphic-unfetch like the tests use.

freezegr commented 3 years ago

Thank you.