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

142
Views
Async Await Returns Empty Array in Console

Going in circles here and hope someone can help guide me. Trying to build an array from a query to later use for a grid table. However, something I am unfamiliar with happens when I try to console.log using the array after the awaited section.

console.log(strandTable.length) comes back as 0. console.log(strandTable) comes back with some empty square brackets [], but when I expand it shows all my data. So all the data is first in a NULL section.

when I try console.log(strandTable[0]) I get an undefined.

    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)

    };
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!