Skip to main content
Question

ReferenceError: input_data is not defined


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_data[“data”] or function it works as expected.

const user = input_data['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 }

 

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.

3 replies

Troy Tessalone
Forum|alt.badge.img+14

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

 


  • Author
  • Beginner
  • 1 reply
  • April 12, 2022
Troy Tessalone wrote:

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


Troy Tessalone
Forum|alt.badge.img+14

@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