我正在尝试创建一个条纹设置密钥并返回该密钥,以便可以在我的快速代码中使用它。 这是功能 然后我这样调用函数 我在此代码中不断收到错误声明 表达式类型不明确,没有更多上下文 在此代码 返回通话响应的最佳方式是什么? ...
提示:本站收集StackOverFlow近2千万问答,支持中英文搜索,鼠标放在语句上弹窗显示对应的参考中文或英文, 本站还提供 中文繁体 英文版本 中英对照 版本,有任何建议请联系yoyou2525@163.com。
更新:我能够找到问题的根源-它似乎与lodash中的循环引用有关,该循环引用在序列化响应时发生。 显然,我需要返回一种特定的承诺,但是我还无法弄清楚该怎么做。
更新结束。
我正在尝试从pub获取官方的云功能示例,以使用包firebase_functions_interop将dart代码转换为基于可部署节点的云功能来与dart一起使用。 我按照本教程设置了构建运行器等(并且他们的示例对我有用)。
现在来讨论这个问题的所有可调用函数。
这是一个使用JavaScript的有效示例:
// JavaScript
const functions = require('firebase-functions');
exports.listFruit = functions.https.onCall(() => {
return [
"Apple",
"Banana",
"Cherry",
"Date",
"Fig",
"Grapes"
];
});
这是我使用dart想到的:
// Dart
import 'package:firebase_functions_interop/firebase_functions_interop.dart';
void main() {
functions['listFruit'] = functions.https.onCall((data, context) => listFruit);
}
FutureOr<List<String>> listFruit(dynamic data, CallableContext context) {
return ['Apple', 'Banana', 'Cherry', 'Date', 'Fig', 'Grapes'];
}
但是执行后,我得到此控制台输出和500错误:
i functions: Beginning execution of "listFruit"
> Response cannot be encoded. Closure 'minified:ns' dh {
> '$initialize': [Function: dh],
> constructor: [Function: static_tear_off],
> '$static_name': 'ns',
> '$S': [Function (anonymous)],
> '$2': [Function: ns] {
> '$callName': '$2',
> '$R': 2,
> '$D': null,
> '$stubName': 'ns',
> '$tearOff': [Function (anonymous)]
> },
> '$C': [Function: ns] {
> '$callName': '$2',
> '$R': 2,
> '$D': null,
> '$stubName': 'ns',
> '$tearOff': [Function (anonymous)]
> },
> '$R': 2,
> '$D': null
> }
> {"severity":"ERROR","message":"Unhandled error Error: Invalid response, check logs for details\n at Object.d (/test_dart_functions/functions/build/index.dart.js:183:3)\n at h3.$2 (/test_dart_functions/functions/build/index.dart.js:4066:9)\n at Object.m4 (/test_dart_functions/functions/build/index.dart.js:138:112)\n at mE (/test_dart_functions/functions/build/index.dart.js:1872:10)\n at /test_dart_functions/functions/build/index.dart.js:1866:42\n at newHandler (/usr/local/Cellar/firebase-cli/9.1.0/libexec/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:286:16)\n at func (/test_dart_functions/functions/node_modules/firebase-functions/lib/providers/https.js:273:32)\n at /test_dart_functions/functions/node_modules/firebase-functions/lib/providers/https.js:293:44\n at cors (/test_dart_functions/functions/node_modules/cors/lib/index.js:188:7)\n at /test_dart_functions/functions/node_modules/cors/lib/index.js:224:17 {\n dartException: HttpsError: Invalid response, check logs for details\n at Object.n9 (/test_dart_functions/functions/build/index.dart.js:1825:15)\n at bD.aO (/test_dart_functions/functions/build/index.dart.js:4023:24)\n at h3.$2 (/test_dart_functions/functions/build/index.dart.js:4066:13)\n at Object.m4 (/test_dart_functions/functions/build/index.dart.js:138:112)\n at mE (/test_dart_functions/functions/build/index.dart.js:1872:10)\n at /test_dart_functions/functions/build/index.dart.js:1866:42\n at newHandler (/usr/local/Cellar/firebase-cli/9.1.0/libexec/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:286:16)\n at func (/test_dart_functions/functions/node_modules/firebase-functions/lib/providers/https.js:273:32)\n at /test_dart_functions/functions/node_modules/firebase-functions/lib/providers/https.js:293:44\n at cors (/test_dart_functions/functions/node_modules/cors/lib/index.js:188:7) {\n code: 'internal',\n details: \"Closure 'minified:ns'\",\n httpErrorCode: { canonicalName: 'INTERNAL', status: 500 }\n }\n}"}
i functions: Finished "listFruit" in ~1s
我真的很期待用dart编写我的所有云函数-除了onCall之外,其他的似乎都可以正常工作。
任何帮助将不胜感激!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.