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.