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

269
Views
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
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!