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

161
Views
Cargue json una vez y use el archivo de contenido FUERA de la función

lo siento, ¿alguien puede mostrarme el código y explicarme cómo puedo cargar solo una vez el archivo json y usar todo el archivo de contenido FUERA de la función?

 let jsonCompleto fetch('uno.json') .then(function (response) { return response.json(); }) .then(function (data) { todo = data.length console.log(todo) jsonCompleto = data console.log(jsonCompleto) // this return all the json file correctly }) console.log(jsonCompleto) // this return undefined // how can load only once the json file and use all content of json file OUTSIDE the function ?
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puedes usar async/await

 "use strict"; const myFetch = async () => { const response = await fetch('https://jsonplaceholder.typicode.com/posts/1') return response.json() } const myFunc = async () => { data = await myFetch() console.log(data) } myFunc()

puede ver la documentación gratuita de recuperación

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!