Skip to main content

Hi there, 

I am attempting to retreive some JSON data from an API so I can parse out information to a gsheet. 

The aim is to get raw JSON from the GET request in “code by Zapier”. 

I’ve been successful in getting the JSON via the webhooks by zapier GET zap but I need raw JSON out so I can properly parse out the sections I need. 

This is the API call from a swagger page. 

const options = {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer 059c02e83998cdeddXXXXXXXXXX'
}
};

fetch('https://api.fsomeurl.co/api/v1.0/menus/75966', options)
.then(response => console.log(response))
.catch(err => console.error(err));

Obvioulsy when I try to use this code in code by zapier I get an error 

 

If you are doing async (with fetch library) you need to use a callback!

 

I am not proficcent in Javascript but I do have a template that I can apply to the raw JSON to parse the information that I require in the next code by zapier step. 

 

Any help in forming the GET request would be greatly appreciated. 

Thanks in advance

Hi @MysterD 

Make sure to reference the available help articles for the Code app: https://zapier.com/apps/code/help


@MysterD 

Usually, If I am using fetch in my code block steps. I will format it like so

const request = await fetch(INSERTURL, {
method: "GET",
headers: {
Accept: 'application/json',
Authorization: 'Bearer 059c02e83998cdeddXXXXXXXXXX'
},
});
const data = await request.json();

 

You can then return the data or continue to work with the raw data. 


Hi there @MysterD were you able to get this one figured out? Let us know if you still need help!