【问题标题】:Why invoking firebase cloud function on local simulator doesn't return any output?为什么在本地模拟器上调用 firebase 云功能不返回任何输出?
【发布时间】:2017-11-24 19:07:04
【问题描述】:

我想在部署之前调用(或测试)我的云功能。我找到了这个参考https://firebase.google.com/docs/functions/local-emulator

我正在使用 shell 为我的函数调用和传递测试数据,但我总是得到响应为 成功调用的函数。我的函数中使用 console.log( ),但永远不会被打印出来。

firebase > post_deleted({"brand" : "Gucci","category" : "FULL LOOKS","postNumImages" : 1,"posterId" : "HcK5eIKU6jUlqhcg7t10OThZ2mq2","posterName" : "Steve Nash","reverseTimestamp" : -1.511338246002482E9,"salePrice" : 5,"size" : "medium","state" : "OPEN","subCategory" : "CASUAL","timestamp" : 1511338246036},{params:{postId:'-KzXlrvMtQ4PnDMiojz8'}})
'Successfully invoked function.'

firebase >

firebase >

我的功能代码(部分)

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
console.log("before");
var gcloud_storage = require('@google-cloud/storage')({keyFilename: 
`${functions.config().serviceaccount.filename}`});
exports.post_deleted = functions.database.ref('/posts/{postId}').onDelete((event) => {
console.log("inside");
let postId = event.params.postId;
let snapshot = event.data.previous;
let subCategory = snapshot.child('subCategory').val();
let db = admin.database();
let tasksArray = [];

来自文档。 Cloud Functions shell 将日志从您的函数流式传输到它们运行的​​终端窗口。它们显示你的函数中的 console.log()、console.info()、console.error() 和 console.warn() 语句的所有输出

那么,为什么我在调用函数时看不到内部?我部署了相同的功能,它按预期工作。对不起,如果我遗漏了一些明显的东西。寻求建议。谢谢。

【问题讨论】:

    标签: firebase testing firebase-realtime-database google-cloud-functions


    【解决方案1】:

    好的。在感恩节度过了两天之后!最后,发现它的一个错误并创建了一个问题on the cloud-functions-emulator sdk

    Later found out there was already the same issue created a week ago

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-19
      • 2019-07-08
      • 2021-02-26
      • 2020-03-18
      • 2019-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多