Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

180
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda