Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda