title: Firebase DocumentSnapshot with Promises getting undefined
body: <p>I have a query that gets a document collection, then iterates over the collection of returned documents looking up additional data. This is done in a <code>forEach</code> loop, adding the document to an array returning <code>Promise.all(array)</code>.</p>
  <p>From here I can chain another <code>then(snapshot =&gt; { })</code> to get the items in the array returned from the Promise, however the problem is when I invoke the method <code>data()</code> to get a plain old javascript object it's always returning <code>undefined</code>.  I'm not sure how to resolve this.</p>
  <p>Here's the Firebase Cloud Function:</p>
  <pre class="lang-js prettyprint-override"><code>exports.cloudFunctionApi = functions.https.onCall(async(data, context) =&gt; {
     admin.firestore().collection(&quot;myDocuments&quot;).get()
     .then(snapshot =&gt; {
        const promises = []
        snapshot.forEach(item =&gt; {
           if(item.id == &quot;abc123&quot;) {
              const data = item.data()
              const p = admin.firestore().doc(`myDocumentDetail/${item.id}`).get()
              promises.push(p)
           }
        })
        return Promise.all(promises)
     })
     .then(snapshot =&gt; {
        snapshot.forEach(item =&gt; {
           const data = item.data()
           console.log(`data is:  ${data}`)   // &lt;- data is undefined
        })
     })
     .catch(error =&gt; {
        console.error(`Error: ${error}`)
     })
  })
  </code></pre>
  <p>I was getting some dumb warnings about <code>const promises = []</code> which I resolved in tsconfig.json file, the settings are:</p>
  <pre><code>{
     &quot;compilerOptions&quot;: {
        &quot;module&quot;: &quot;commonjs&quot;,
        &quot;noImplicitReturns&quot;: true,
        &quot;noUnusedLocals&quot;: true,
        &quot;outDir&quot;: &quot;lib&quot;,
        &quot;sourceMap&quot;: true,
        &quot;target&quot;: &quot;es2017&quot;,
        &quot;resolveJsonModule&quot;: true
      },
      &quot;compileOnSave&quot;: true,
      &quot;include&quot;: [
         &quot;src&quot;
       ],
       &quot;strictNullChecks&quot;:false
  }
  </code></pre>