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

77
Views
Async Await pero mal?`

Soy bastante nuevo en esto y aparentemente no entiendo las llamadas asíncronas ...

La siguiente función hace en el caso de "claimRewards" una llamada Api. Pensé que con Async Await la promesa se resuelve en un valor utilizable, pero en su lugar, la función devuelve una promesa como:

 amount: Promise {<fulfilled>: '198816.61958'}

Por qué es este el caso. no importa si envuelvo el async await alrededor de la función fetchApi o la función transactionCases, o lo dejo por completo. ¡Sospecho que lo estoy usando mal, pero no puedo entender por qué es así! por favor ayuda y amable gracias por su consejo.

 async function transactionCases(cases, data) { const url = 'https://api.elrond.com/transactions?withOperations=true&hashes=' + data.txHash; switch (cases){ case 'claimRewards': const claimRewards = await fetchApi(url).then(data => { var filtered = data[0].operations.filter(operation => operation.action.includes("addQuantity")) return converttodecimals(filtered[0].value); }); return claimRewards; break; default: "No Result"; } } function fetchApi(url) { return fetch(url) .then(response => response.json()) .then(data => data) .catch(error => console.log(error)); }
about 4 years ago · Juan Pablo Isaza
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!