gpt4 book ai didi

node.js - Firebase 函数错误 : The default Firebase app does not exist

转载 作者:行者123 更新时间:2023-12-05 08:39:16 25 4
gpt4 key购买 nike

以前,该功能有效。但是我添加了一些代码,现在这个错误来了。如何解决这个问题?

Error: Error occurred while parsing your function triggers.

Error: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services.
at FirebaseAppError.FirebaseError [as constructor] (/Users/demo/functions/node_modules/firebase-admin/lib/utils/error.js:42:28)

代码

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
import { getLocations, getLocationsByType } from '../service/locationQuery/locationQuery';

//I tried both way, but same error came
// admin.initializeApp(functions.config().firebase);
admin.initializeApp();
exports.findUsers = functions.https.onCall(async (data: any, context: any) => {

最佳答案

我更改了初始化位置.. 现在可以正常工作了。我不知道为什么会这样。

import * as admin from 'firebase-admin';
admin.initializeApp();//add to here
import { getLocations, getLocationsByType } from '../service/locationQuery/locationQuery';

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

exports.findUsers = functions.https.onCall(async (data: any, context: any) => {

关于node.js - Firebase 函数错误 : The default Firebase app does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60262246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com