小编kre*_*ndo的帖子

无法在本地测试云功能,模拟器无法以TypeError开头:_onRequestWithOpts不是函数

当我尝试从项目中的functions目录启动外壳程序进行本地测试时,模拟器会启动,但无法加载我的函数。

当我运行“ npm run build”时,我没有收到任何错误。怎么了?

我尝试删除功能目录并使用firebase-tools cli再次创建它,但仍然出现相同的错误。我还导出了管理员凭据。

我正在使用从firebase-tools cli生成的index.ts文件中创建的默认方法。

import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';

admin.initializeApp();
// // Start writing Firebase Functions
// // https://firebase.google.com/docs/functions/typescript
//
export const helloWorld = functions.https.onRequest((request, 
response) => {
 response.send("Hello from Firebase!");
});
Run Code Online (Sandbox Code Playgroud)

我希望仿真器启动该函数的实例进行测试,但相反,我看到此错误:

?  functions: Emulator started at http://localhost:5001
?  TypeError: _onRequestWithOpts is not a function
at Object.httpsProvider._onRequestWithOpts (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:278:24)
at Object.httpsProvider.onRequest (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:283:34)
at Object.<anonymous> (/Volumes/G-DRIVE mobile USB-C/CLEAN UP/Documents/code_bank/typescript/theincrowdapp/functions/lib/index.js:9:38)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at …
Run Code Online (Sandbox Code Playgroud)

typescript google-cloud-functions firebase-cli

11
推荐指数
1
解决办法
1448
查看次数

将 Firebase 存储的“数组”对象转换为 POJO

我正在尝试在 Android 应用程序的 recyclerview 中从 firebase 检索数据。我引用的“boardz”节点上的对象有 2 个子属性。这些属性每个都有多个子属性。

使用 Firebase json 和 pojo 更新:

{
"game" : {
"boardz" : {
  "-KTaL6V06e3SkEAvfU_3" : {
    "hostData" : {
      "hostId" : "MUC6gtRqInRQmqxe7khlmrAbjVZ2",
      "ownerAddress" : "n3b9t3vDR6Yiot4HwxwZoa7vxZBiAKReeH",
      "secretString" : "derp-a-derp"
    },
    "metadata" : {
      "across" : [ 2, 0, 5, 9, 7, 8, 1, 4, 3, 6 ],
      "awayTeam" : "ATL",
      "boardFeeBTC" : "",
      "boardFeeUSD" : 14,
      "collectionAddress" : "2NEPnGPyvy9F5N4W4CjhLNPZLwTFNSAzjAL",
      "down" : [ 1, 6, 8, 7, 3, 5, 2, 0, 9, 4 …
Run Code Online (Sandbox Code Playgroud)

android firebase android-recyclerview firebase-realtime-database

5
推荐指数
1
解决办法
2137
查看次数