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

141
Views
Sacar a json de una promesa de búsqueda

Encontré una pregunta similar aquí , pero cuando trato de alejar la matriz de la declaración entonces, simplemente no recibo nada.

El siguiente código muestra en la consola exactamente la matriz que quiero:

 var url = "http://localhost:5000/products"; async function getJSON(x){ let response = await fetch(x); let data = await response.json(); return data; } getJSON(url).then(data => console.log(data));

 0: {id: '1', name: 'xxxxx', price: 28.8, x parcelamento: Array(2), color: 'gray', …} 1: {id: '2', name: 'xxxxx', price: 398, parcelamento: Array(2), color: 'black', …} 2: {id: '3', name: 'xxxxx', price: 398.8, par...

Pero quiero que esta matriz salga de "entonces". Probé de varias maneras sin éxito:

 var url = "http://localhost:5000/products"; async function getJSON(x){ let response = await fetch(x); let data = await response.json(); return data; } array = getJSON(url).then(data => data); console.log(array);

En cambio, recibo una promesa y simplemente no puedo acceder a la matriz:

 Promise {<pending>} [[Prototype]]: Promise[[PromiseState]]: "fulfilled" [[PromiseResult]]: Array(14)

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!