Voy en círculos aquí y espero que alguien pueda ayudarme a guiarme. Intentando construir una matriz a partir de una consulta para usarla más tarde en una tabla de cuadrícula. Sin embargo, sucede algo con lo que no estoy familiarizado cuando trato de console.log usando la matriz después de la sección esperada.
console.log(strandTable.length) regresa como 0. console.log(strandTable) regresa con algunos corchetes vacíos [], pero cuando lo expando, muestra todos mis datos. Entonces todos los datos están primero en una sección NULL.
cuando pruebo console.log(strandTable[0]) obtengo un valor indefinido.
async function viewStrandInfo() { var strandTable = [] let cableObjectId = view.popup.selectedFeature.attributes.OBJECTID let bufferQuery = { outFields: ["OBJECTID", "BUFFERTUBENUMBER", "BUFFERTUBECOLOR", "BUFFERTUBENAME"], relationshipId: fibrecableLayer.relationships[0].id, objectIds: cableObjectId } let buffers = await fibrecableLayer.queryRelatedFeatures(bufferQuery) await buffers[cableObjectId].features.forEach((buffer) => { let bufferObjectId = buffer.attributes.OBJECTID let strandQuery = { outFields: ["OBJECTID", "FIBERNUMBER", "FIBERCOLOR", "ADMINLABEL", "STATUS", "OWNER", "ADMINISTRATOR", "HOT_CIRCUIT_ID", "COMMENTS", "RESERVEDFOR"], relationshipId: buffTable.relationships[0].id, objectIds: bufferObjectId } buffTable.queryRelatedFeatures(strandQuery).then((result) => { result[bufferObjectId].features.forEach((strand) => { strandTable[strand.attributes.FIBERNUMBER] = { strand: strand.attributes.FIBERNUMBER, buffer: buffer.attributes.BUFFERTUBENUMBER, adminlabel: strand.attributes.ADMINLABEL, status: strand.attributes.STATUS, owner: strand.attributes.OWNER, admin: strand.attributes.ADMINISTRATOR, cctid: strand.attributes.HOT_CIRCUIT_ID, comments: strand.attributes.COMMENTS, reservedfor: strand.attributes.RESERVEDFOR } }) }) }) console.log(strandTable.length) console.log(strandTable) };