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

"fetch is not defined" #82

Closed
kdev opened this issue May 1, 2020 · 1 comment
Closed

"fetch is not defined" #82

kdev opened this issue May 1, 2020 · 1 comment

Comments

@kdev
Copy link

kdev commented May 1, 2020

Env

Node: v13.0.1
OS: Windows (Version 10.0.18363.778)
Package: @giphy\js-fetch-api (Version: 1.5.9)

To Reproduce

  1. Have a basic node.js project set up
  2. Run npm i @giphy\js-fetch-api
  3. Run project

Code

const { GiphyFetch } = require("@giphy/js-fetch-api");
const giphy = new GiphyFetch("api key");
//...
const { data } = giphy.random();
console.log(data);

Error

(node:39764) UnhandledPromiseRejectionWarning: Error: fetch is not defined
    at new FetchError (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\fetch-error.js:21:28)
    at Object.<anonymous> (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:90:38)
    at step (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:33:23)
    at Object.next (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:14:53)
    at D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:4:12)
    at makeRequest (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:52:48)
    at Object.request [as default] (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\request.js:101:27)
    at GiphyFetch.random (D:\Developement\mod-and-music\node_modules\@giphy\js-fetch-api\dist\api.js:104:33)
(node:39764) 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(). (rejection id: 1)
(node:39764) [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.  
@giannif
Copy link
Collaborator

giannif commented May 4, 2020

@KokosnussDEV you need to add the fetch polyfill yourself, see my comment here: #58 (comment)

I will work on documenting this more clearly

@giannif giannif closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants