Hi! I’m building an Action and trying to use `fetch` via code mode. However, when doing so I receive a “ReferenceError: fetch is not defined”. In doing some research, it appears that Node.js needs to be v18 in order to use this. Is this correct? Is there a workaround?
const options = {method: 'GET', headers: {accept: 'application/json'}};
fetch('https://api.portal.scanifly.com/api/v1/designs/', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/0dbde897-f5ae-49ed-8f6a-8e8c8fd75219.jpg)
I’ve also tried the below courtesy of
const Project_Id = ""; // Include your own project ID
const Access_Token = ""; // Include your own access token
let appData = "";
try {
const appResp = await fetch(
`https://api.portal.scanifly.com/api/v1/designs/${Project_Id}?access_token=${Access_Token}`,
{
method: 'GET', // Method
headers: {
'accept': 'application/json'
}
}
);
appData = await appResp.text();
appData = JSON.parse(appData);
} catch (e) {
console.log(e.message);
}
output = [{ appData }]
And received the following error response.
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/95a10c6f-5a4d-43fc-9092-fecb164a6e17.png)
When I ran this is npm.runkit.com/supertest I got the following result.
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/5368dae8-27be-4901-b1d0-132ae925d23d.png)
Ultimately, I’d like to get to where I can use the `params` to pass the projectId and access_token, but I just hardcoded my projectId and access_token to test the code. Here are the screenshots.
params: {
'projectId': bundle.inputData.projectId,
'access_token': bundle.authData.access_token
}
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/1deb22f3-ed9c-4fed-b056-b7c648952678.png)
![](https://uploads-us-west-2.insided.com/zapier-ca/attachment/3ca32b2b-1eca-4165-8775-b1cbfac3a442.png)
Best answer by sgee
View original