title: firebase firestore get object/array from document - js
body: <p>My firestore database currently looks like this:
  <a href="https://i.stack.imgur.com/HKdUV.png" rel="noreferrer">firestore db</a></p>
  
  <p>how can I get the value of, say, DEVICES/ID.
  currently my code returns undefined when i try to get the value.</p>
  
  <pre><code>var userDeviceRef = db.collection("USERS").doc(data.uid);
  userDeviceRef.get().then(function(doc){
      if (doc.exists) {
          console.log("Document data:", doc.data());
          console.log("document customdata foo: " + doc.data().DEVICES.ID);
      }
  }
  </code></pre>
  
  <p><code>data.uid</code> returns a proper value. the value of the document ID.
  <code>doc.data()</code> returns all the fields and its children in what appears to be string format. however when I add <code>DEVICES.ID</code>, it returns undefined. how can i get the nested data as shown in the image?</p>