Skip to main content
Question

Zapier CLI: fetch is not defined

  • October 18, 2022
  • 1 reply
  • 37 views

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.

Did this topic help you find an answer to your question?
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

shalgrim
Forum|alt.badge.img+8
  • Zapier Staff
  • 406 replies
  • October 21, 2022

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