Firebase 功能正在部署,但未显示在控制台中 [英] Firebase function deploying, but not showing up in console

查看:19
本文介绍了Firebase 功能正在部署,但未显示在控制台中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题与问题基本相同

但它没有显示在控制台中.我哪里错了?这是我的 index.js:

const functions = require('firebase-functions');const admin = require('firebase-admin');admin.initializeApp(functions.config().firebase);var delayInMilliseconds = 5000;export.copyRoom=functions.database.ref('/RoomsOwn/${AuthUid}').onWrite((event) => {var uid = event.params.AuthUid;console.log('AuthID:' + uid);var object = event.data.val();console.log('整个对象:', object);设置超时(函数(){return admin.database.ref('/RoomsOthers/${uid}').set(object);},延迟毫秒);});

解决方案

您在运行 firebase deploy 时并未实际部署该功能.如果您已成功部署它,该函数的名称将出现在 Firebase CLI 输出中.

确保你:

  1. 实际上已将文件与您尝试部署的功能一起保存.
  2. 文件位于正确的目录中.对于 JavaScript 项目,默认为 functions/index.js
  3. 正在从正确的目录部署正确的项目.

This question is essentially the same as question 44799104, only that I provide my index.js (and the only answer there was not helpful, as I do include 'exports').

In short, I have deployed my function successfully,

but it does not show in the console. Where am I going wrong? Here is my index.js:

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

var delayInMilliseconds = 5000;


exports.copyRoom= functions.database.ref('/RoomsOwn/${AuthUid}').onWrite((event) => {

    var uid = event.params.AuthUid;
    console.log('AuthID: ' + uid);
    var object = event.data.val();
    console.log('Whole Object: ', object);

    setTimeout(function() {
    return admin.database.ref('/RoomsOthers/${uid}').set(object);
    }, delayInMilliseconds);

  });

解决方案

You didn't actually deploy that function when you ran firebase deploy. If you had successfully deployed it, the name of the function would have appeared in the Firebase CLI output.

Make sure you:

  1. Actually saved the file with the function you're trying to deploy.
  2. The file is in the correct directory. For JavaScript projects, the default is functions/index.js
  3. Are deploying the correct project from the correct directory.

这篇关于Firebase 功能正在部署,但未显示在控制台中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆