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

173
Views
¿Qué está causando este TypeError en mi Google Apps Script?

Estoy tratando de llamar datos de Coin Market Cap a una hoja de Google a través de Apps Script. No entiendo el TypeError que estoy haciendo aquí.

Aquí está el código:

 function getCryptoPrice() { var sh1=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("EPS data CMC"); var url="https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest?symbol=BTC" var requestOptions = { method: 'GET', uri: 'https://pro-api.coinmarketcap.com/v2/cryptocurrency/quotes/latest', qs: { start: 1, limit: 5000, convert: 'USD' }, headers: { 'X-CMC_PRO_API_KEY': '***********hidden*************' }, json: true, gzip: true }; var httpRequest= UrlFetchApp.fetch(url, requestOptions); var getContext= httpRequest.getContentText(); var parseData=JSON.parse(getContext); sh1.getRange(1, 2).setValue(parseData.data.BTC.quote.USD.price) }

Y el error:

 TypeError: Cannot read property 'USD' of undefined getCryptoPrice @ Code.gs:24

Palabras clave : hoja de google, script de aplicaciones, capitalización de mercado de monedas, cotización, último, V2, api,

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

0

Está recibiendo ese error porque parseData.data.BTC está devolviendo una array .

Intenta cambiar esto a: -

 sh1.getRange(1, 2).setValue(parseData.data.BTC.quote.USD.price)

este

 sh1.getRange(1, 2).setValue(parseData.data.BTC[0].quote.USD.price)
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!