如何从云功能获取Firebase项目名称或ID [英] How to get Firebase Project Name or ID from Cloud Function

查看:301
本文介绍了如何从云功能获取Firebase项目名称或ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用云功能,并希望从我的一个Javascript服务器文件中获取项目名称。我知道该值存储在.firebaserc中,但我不认为该文件在服务器上可用,对吧?我想做这样的事情:

I am using Cloud Functions and want to get the project name from within one of my Javascript server files. I know that value is stored in the .firebaserc, but I don't think that file is available on the server, right? I want to do something like this:

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

admin.getProjectName();  // or getProjectID()

functions.getProjectName(); 


推荐答案

谢谢@Frank。答案是:
process.env.GCLOUD_PROJECT

我不确定变量进程的位置来自,但这确实可以获得项目名称。

Thank you @Frank. The answer is: process.env.GCLOUD_PROJECT.
I'm not sure where the variable process comes from, but this does work to get the project name.

这篇关于如何从云功能获取Firebase项目名称或ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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