Skip to main content

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.

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