Nemus
Nemus

Reputation: 1482

How to view logs in Firebase cloudfunctions

I'm writing my very first cloudfunctions app:

import * as functions from "firebase-functions";
import admin = require("firebase-admin")

admin.initializeApp();

export const random_questions = functions.https.onRequest(async (req, res) => {
  const allQuestions = (await admin.database().ref('questions').get()).toJSON();
  functions.logger.log('params', req.params);
  res.send(allQuestions);
});

As you can see I put a log in my app, but is not shown in my terminal or in the ui emulator suite (localhost:4000) or using firebase functions:log.

Edit: UI suite screenshot: random_question is the function I'm testing

What am I missing?

Upvotes: 0

Views: 84

Answers (1)

Nemus
Nemus

Reputation: 1482

I found the issue:

I was testing using:

 firebase emulators:start --only functions

that always run the same code. To run your code after a change use

"npm run build && firebase emulators:start --only functions",

or simply

"npm run serve"

Upvotes: 1

Related Questions