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.
Here it is:
I create a Firebase project test-123xyz. Then I install firebase tools in my terminal.
In the web console I create a firestore database.
Then I run firebase init in terminal, select an existing project (the test-123xyz) and select the function, hosting and firestore services.
The code in the function is:
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) => {
firestore.collection("usuarios").get()
.then(doc => {
return res.send(doc.data());
}).catch(error => {
return res.status(500).send(error);
});
})
exports.app = functions.https.onRequest(app);
It works pretty fine. It access and write in the database. All good.
I access the page *MY_PROJECT.firebaseapp.com/api/cardapio/hoje* and get the JSON.
But then I notice this alert in the billing console in Firebase on Outbounding network
All the others usage is ok, inside the limit. But the way I'm accessing the firestore is counting as an outbounding task.
But I though the usage of firestore is inside the limit of the Spark plan:
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?
*Edit:
This is the log of the function:


