我正在使用 firebase firestore 和 firebase 函数开发一个 flutter 应用程序。我一次又一次地收到此异常 -
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: [firebase_functions/internal] INTERNAL
E/flutter (15454): #0 catchPlatformException (package:cloud_functions_platform_interface/src/method_channel/utils/exception.dart:19:3)
Run Code Online (Sandbox Code Playgroud)
自过去几个小时以来,我一直在尝试解决此异常,但无法取得任何进展。这是 index.js 文件中我的函数的代码。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.addUser = functions.https.onCall(async (data) => {
await admin.firestore().collection("collection_name").add({
name: "my_name",
email: "my_email"
}
);
});
Run Code Online (Sandbox Code Playgroud)
这是我的 flutter 应用程序的 dart 代码。
MyButton(
onPressed: () async {
HttpsCallable a =
FirebaseFunctions.instance.httpsCallable("addUser");
final x = await a();
print(x.data);
},
),
Run Code Online (Sandbox Code Playgroud)
提前致谢 !
firebase flutter google-cloud-functions google-cloud-firestore