I'm learning on how tu use Firebase Function inside an Ionic + Angular project.
I want to create my custom function that will get all the games (a collection) and return an array with these games by order of an attribute called "count". My first step is to get all the games and just display to understand the structure.
Unfortunately, when I run my command firebase emulators:start and I access to my function "getMostPlayedGames" this error appears:
FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created call Firebase App.initializeApp() (app/no-app). at app And here's my index.ts
import * as functions from 'firebase-functions'; import * as admin from 'firebase-admin'; import firebase from 'firebase'; admin.initializeApp(); export const helloWorld = functions.https.onRequest((req, res) => { res.send('Hello world'); }); export const deleteExpiredSessions = functions.https.onRequest((req, res) => { functions.logger.info('Automatic cleaning - Delete expired sessions from Database', { structuredData: true }); res.send('Automatic cleaning - Delete expired sessions from database'); }); export const getMostPlayedGames = functions.https.onRequest((req, res) => { const db = firebase.firestore(); const games = db.collection('games'); console.log(games); functions.logger.info('Get all games', { structuredData: true }); res.send(games); }); The "HelloWorld" function works.