Skip to main content

I am trying to understand a syntax error I am encountering and was hoping what I’m doing wrong.

I am pulling data from a previous step then using this data to make my API call but whenever I add my function an error is thrown ReferenceError: input_data is not defined but when I remove let data = input_datad“data”] or function it works as expected.

const user = input_datan'user_data'] //123
const getUser = async (user) => {
const token = "...";
const endpoint = `https://example.com/test?user=${userId}`;
const request = await fetch(endpoint, {
method: "GET",
headers: {
"Content-Type": "application/json; charset=utf-8",
"Authorization": token,
"Accept": "application/json",
},
});
const response = await request.json();
return response;
}

const result = await getUser(user);
output = { result }

 

Hi @Jameswin 

Good question.

Another option is to use the Webhooks app as an action step to make a GET Request: https://zapier.com/apps/webhook/help

 


Hi @Jameswin 

Good question.

Another option is to use the Webhooks app as an action step to make a GET Request: https://zapier.com/apps/webhook/help

 



Hey Troy,

I understand there is other ways to perform get request however I am trying to understand why Input_data is not referenced? I don’t see an issue with the code, it is important for us to use code by zapier as we will perform more than 1 action


@Jameswin 

Looks like you are using a combo of JavaScript and Python syntax.

 

Code help articles with examples…

Javascript: https://zapier.com/help/create/code-webhooks/javascript-code-examples-in-zaps

Python: https://zapier.com/help/create/code-webhooks/python-code-examples-in-zaps

 

Observations

Make sure to correct to use single quotes .

There is no userId variable defined.

 

Missing the closing ;

should be inputData.user_data