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

369
Views
¿Hay alguna manera de establecer el estado de una matriz en un bloque .then ()?

`

  1. Tengo una matriz de puntos (ciudad, estado)
  2. Hago una llamada de búsqueda para convertir mis puntos a (latitud y longitud), así que empujo el resultado a una matriz e intenté establecer el estado de la matriz, pero cuando consola. log (arreglo) obtuve []. `
 if (pointsComplete) { // for (let i = 0; i < pointsComplete.length; i++) { for await (let x of pointsComplete) { if (x.city !== "") { fetch( `https://singlesearch.alk.com/na/api/search?&query=${x.city} , ${x.state}&maxResults=1`, { method: "GET", headers: { "Content-Type": "application/json", Authorization: trimble_key, }, } ) .then((response) => response.json()) .then((data) => { pointsCoords.push({ Lat: data.Locations[0].Coords.Lat, Long: data.Locations[0].Coords.Lon, position: parseInt(x.position), }); }) .finally(() => { setPointsCoordsArray(pointsCoords); }); } } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Esto funcionó para mí ..

 if (pointsComplete) { let promises = []; for (let x of pointsComplete) { if (x.city !== "") { promises.push( fetch( `https://singlesearch.alk.com/na/api/search?&query=${x.city} , ${x.state}&maxResults=1`, { method: "GET", headers: { "Content-Type": "application/json", Authorization: trimble_key, }, } ) .then((response) => response.json()) .then((data) => { pointsCoords.push({ Lat: data.Locations[0].Coords.Lat, Long: data.Locations[0].Coords.Lon, position: parseInt(x.position), }); }) ); } } Promise.all(promises).then((data) => { setPointsCoordsArray(pointsCoords); console.log("______________"); }); }
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!