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

145
Visualizações
Fetch data via GS - response code 200 but data always "undefined"

I try to fetch the data given by https://api.llama.fi/charts/Ethereum

It looks like

[{"date":"1546560000","totalLiquidityUSD":273845651.27077854},{"date":"1546646400","totalLiquidityUSD":288674544.41292274},{"date":"1546732800","totalLiquidityUSD":297321259.6930144},{"date":"1546819200","totalLiquidityUSD":286168221.103729},{"date":"1546905600","totalLiquidityUSD":285073686.76345384}, ...

when I open it in chrome.

In python with urllib.request.urlopen() it works fine.

Here in Google Sheets I try

function myFunction() {
  var data = UrlFetchApp.fetch("https://api.llama.fi/charts/Ethereum").getResponseCode()
  var data2 = UrlFetchApp.fetch("https://api.llama.fi/charts/Ethereum").getContentText()
  console.log(UrlFetchApp.fetch("https://api.llama.fi/charts/Ethereum").getContentText())
}

Here data = 200, but data2 = undefined. I think it is a newbie question, but I am unfamiliar with JS or GS.

Thanks for your help!

Best,

Dominik

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can access the data as JSON object by parsing the ContentText as JSON, then you can iterate the data with a for or use it in any other way you need.

function myFunction() {
  var response = UrlFetchApp.fetch("https://api.llama.fi/charts/Ethereum").getContentText()
  
  var data = JSON.parse(response);
  for(const d of data) {
    console.log("DATE: " + d.date)
    console.log("LIQUIDITY: " + d.totalLiquidityUSD)
  }
}

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