Question

Zapier CLI: fetch is not defined

  • 18 October 2022
  • 1 reply
  • 33 views

Userlevel 1

I’m creating an App using Zapier CLI. I’m trying to use the fetch function but it says it’s not defined.

Code example:

 

const res = await fetch('http://example.com/');

Error:

Executing creates.new_article.operation.perform with bundle fetch is not defined

 

I want to encode an image to base64 using this example.

 

Appreciate your help.


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 6
Badge +8

Hi @machadoug !

Have you installed fetch from npm? The example you point to is for a Code by Zapier step, which would already have it installed.

For a CLI app, I’d try `npm install node-fetch` from the command line and then in your code you’ll have to import it first like const fetch = require('node-fetch');

 

I hope that helps! Let us know if you have any more questions