title: Get access firestore data within a function in Firebase
body: <p>I'm trying to access my the firestore data within a Firebase function... I'm new at Firebase and didn't understand exactly somethings... I read lots of the documentation and FAQs and nothing explain my question. </p>
  
  <p>Here it is:</p>
  
  <p>I create a Firebase project <code>test-123xyz</code>. Then I install firebase tools in my terminal. 
  In the web console I create a firestore database.
  Then I run <code>firebase init</code> in terminal, select an existing project (the <code>test-123xyz</code>) and select the <strong>function</strong>, <strong>hosting</strong> and <strong>firestore</strong> services.</p>
  
  <p>The code in the function is:</p>
  
  <pre class="lang-js prettyprint-override"><code>const functions = require('firebase-functions');
  const express = require('express');
  const admin = require("firebase-admin");
  
  admin.initializeApp();
  
  const firestore = admin.firestore();
  const app = express();
  
  app.get('/api/usuarios', (req, res) =&gt; {
  
    firestore.collection("usuarios").get()
     .then(doc =&gt; {
       return res.send(doc.data());
     }).catch(error =&gt; {
       return res.status(500).send(error);
     });
  
  })
  
  exports.app = functions.https.onRequest(app);
  </code></pre>
  
  <p>It works pretty fine. It access and write in the database. All good.
  I access the page <code>*MY_PROJECT.firebaseapp.com/api/cardapio/hoje*</code> and get the JSON.</p>
  
  <p>But then I notice this alert in the billing console in Firebase on <code>Outbounding network</code></p>
  
  <p><a href="https://i.stack.imgur.com/RcmTF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RcmTF.png" alt="enter image description here"></a></p>
  
  <p>All the others usage is ok, inside the limit. 
  But the way I'm accessing the firestore is counting as an outbounding task.</p>
  
  <p>But I though the usage of firestore is inside the limit of the Spark plan:</p>
  
  <p><a href="https://i.stack.imgur.com/7lCoS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7lCoS.png" alt="enter image description here"></a></p>
  
  <p>My question is: Is the a diferent way to access the firestone within a firebase function that make this works. Or if I want to access the database from a function I need to pay this as an outbounding connection? </p>
  
  <p>*Edit:</p>
  
  <p>This is the log of the function:</p>
  
  <p><a href="https://i.stack.imgur.com/TclCo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TclCo.png" alt="enter image description here"></a></p>