Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

282
Vistas
Empty array, which when expanded have objects, after POST fetch

I'm making the 2024 game with the Hexes and I have a RNG server, which gives me the random coordinates and values for new blocks whenever button is clicked. The problem is that, when I make and POST fetch for this data and I remove the promise, I end up with an array, which does not exactly work as one.This is how it looks in console.

The code is

  let cellsValueArray = [];
  
  async function callAsync(radius, cellsWithValue=[]) {
    let startGameCells = [];
    let filledCells = startGameCells.concat(cellsWithValue);
    let rawResponse = await fetch(`http://localhost:13337/${radius}`, {
      method: 'POST',
      mode: 'cors',
      body: JSON.stringify(filledCells),
    })
    let content = await rawResponse.json();
    cellsValueArray.push.apply(cellsValueArray, content);
  };
  callAsync(radius);

I want to have an ability to do stuff with this array like array.x array.y array.value, to change the value of hex objects on the DOM. I tried array[0].x, which sometimes works, but the return Error( cannot assign methods to undefined). So array[0] returns undefined.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda