title: How to get data from Firestore in Cloud Function?
body: <p>I need to know what I'm doing wrong here?</p>
  
  <p>I'm calling this function from Flutter. The call back is getting done correctly and the first &amp; second prints are coming in the "log" on Firbase. But getting undefined from the "Firestore"!!</p>
  
  <p>This is the code in the Cloud Function:</p>
  
  <pre><code>var functions = require("firebase-functions");
  let admin = require('firebase-admin');
  admin.initializeApp(functions.config().firebase);
  admin.firestore().settings({ timestampsInSnapshots: true });
  
  
  exports.storeContact5 = functions.https.onCall((data, context) =&gt; {
      // First print is working fine
      console.log('test');
      var recieverId = 'WqHxLoYvRxR9UK8sFJZ9WxTOIE32';
      const check = admin.firestore().collection('users').doc(recieverId).get();
      check.then(testValue =&gt; {
          console.log(testValue.data.nickname);
          return true;
      }).catch(err =&gt; {
          console.log('Error getting document', err);
      });
      console.log('test2');
      // Return to flutter App (Working fine)
      return {
          repeat_message: 'ok!'
      }
  });
  </code></pre>
  
  <p>Screenshot for Firebase Log</p>
  
  <p><a href="https://i.stack.imgur.com/g21OJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g21OJ.png" alt="enter image description here"></a></p>