【问题标题】:Firebase Functions throw function with internal error [closed]Firebase Functions 引发内部错误的函数 [关闭]
【发布时间】:2020-10-27 18:32:57
【问题描述】:

我正在使用 Firebase 功能在 Firebase 托管下开发一个项目。 索引.js:

exports.simpleFunction = functions.https.onCall((data, context) => {
    return data;
});

索引.html:

var simpleFunction = firebase.functions().httpsCallable('simpleFunction');
    
simpleFunction("12").then (function(result) {
                                    console.log(result);
                                }).catch(function(error) {
                                    console.log("Error code:" + error.code);
                                });

在控制台中我只得到:

“错误代码:内部”

谁能帮我弄清楚发生了什么?

【问题讨论】:

  • 您使用的是哪个版本的 Firebase 客户端 SDK?函数控制台上的错误日志说明了什么?
  • 天啊!!!!版本 vas 7.21.1,我不得不更改为 8.0.0。非常感谢!!!

标签: javascript node.js firebase google-cloud-functions


【解决方案1】:

我在我的项目中重现了您的场景,您的代码按预期工作,这是我的 HTML 文件

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Welcome to Firebase Hosting</title>
    <script  src="/__/firebase/8.0.0/firebase.js"></script>
    <script  src="/__/firebase/8.0.0/firebase-app.js"></script>
    <script  src="/__/firebase/8.0.0/firebase-functions.js"></script>
    <script  src="/__/firebase/init.js"></script>

    <style media="screen">

    </style>
</head>
<body>

Hello world!!


</body>

<script>html
    let simpleFunction = firebase.functions().httpsCallable('simpleFunction');

    simpleFunction("12").then(function (result) {
        console.log(result);
    }).catch(function (error) {
        console.log("Error code:" + error.code);
    });
</script>
</html>

我正在使用最新的 firebase 网络包,我的功能支持unauthenticated access

更新我能够重现此问题

我尝试调用另一个函数(python 函数),但由于 python 上不存在 firebase-functions 包,这看起来是根本原因,请尝试更新您的 firebase-functions 包或尝试使用我的复制示例。

package.json

{
  "name": "sample-http",
  "version": "0.0.1",
  "dependencies": {
    "firebase-admin": "~9.2.0",
    "firebase-functions": "^3.11.0"  
  }
}

功能

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


exports.simpleFunction = functions.https.onCall((data, context) => {
    return data;
});

【讨论】:

  • 非常感谢!这是关于我使用的版本......现在它正在工作! :)
  • 谢谢你,你帮我省了很多挫折:D
猜你喜欢
  • 2021-06-02
  • 2017-10-05
  • 1970-01-01
  • 2021-10-23
  • 1970-01-01
  • 2018-06-17
  • 2020-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多