Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
How to call a function and use it's return value?

I am not sure how I can pass params in a function, currently I want to store an access token in one function and then pass the params into another function, is there something I am missing or doing wrong?

function access_token()
{
  var token = zauthorization().access_token;

  var header = 
  {
    "Authorization":"Zoho-oauthtoken " + token
  }

  return header
}

function module(access_token)
{

   var options = 
  {
    "method":"get",
    "headers": header
  }
  
  var url = "https://recruit.zoho.com/recruit/v2/CustomModule1"
  var res = UrlFetchApp.fetch(url,options)
  return JSON.parse(res)
}

So in short I am not sure how I can pass the header into my next function, I need to have it done that way to go onto the next function, I need to create another function after this which will allow me to access data in a specific module so I can have the counted rows returned, I just need to know how to pass parameters in a new function from another function that can be used.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

It seems a bit simple what I think you are asking, but the only thing I can think is: You call a function by writing it's name and pass arguments in brackets separated by a comma if there are more.

myFunction(parameter1,parameter2,55,'This is a text string passed.')

parameter1 and 2 are variables, then a number, then a text string.

about 4 years ago · Juan Pablo Isaza Report

0

I'm not sure but I think you can do it like this:

Since your first function returns the header

function myfunk() {
  var token = zauthorization().access_token;
  var header = { "Authorization": "Zoho-oauthtoken " + token }
  return header;
}

function module() {
  var options = { "method": "get", "headers": myfunk() };
  var url = "https://recruit.zoho.com/recruit/v2/CustomModule1"
  var res = UrlFetchApp.fetch(url, options)
  return JSON.parse(res)
}

Or more simply perhaps this:

function module() {
  var options = { "method": "get", "headers": { "Authorization": "Zoho-oauthtoken " + zauthorization().access_token } };
  var url = "https://recruit.zoho.com/recruit/v2/CustomModule1"
  var res = UrlFetchApp.fetch(url, options)
  return JSON.parse(res)
}

But I'm not familiar with what zauthorization() is so I could be totally off base here. If so sorry.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!