简体   繁体   English

Firebase 函数将对象打印到控制台

[英]Firebase Functions print an object to the console

I have this code on the Firebase cloud using functions我使用函数在 Firebase 云上有这段代码

peopleDataBase.orderByChild("mCalculateFaceSizeWidth")
                        .endAt(mCalculateFaceSizeWidth())
                        .limitToLast(1)
                        .on("child_added", function(snapshot) {
                       var  person = {
                                "name":snapshot.val().name,
                                "age":snapshot.val().age,
                                "id":snapshot.val().id,
                                "children":snapshot.val().children,
                                "address":snapshot.val().address,
                                "image":snapshot.val().image
                            }

                            if(key != snapshot.key){
                                people += person;
                                key = snapshot.key;
                                console.log("The entire people list:",people);
                            }

                        });

I am trying to print the people object to the console, I have searched for an hour using JSON.stringify and String even $scope and other methods, nothing worked.我正在尝试将人员对象打印到控制台,我已经使用 JSON.stringify 和 String 甚至 $scope 和其他方法搜索了一个小时,但没有任何效果。 In the log on the cloud I am getting在云上的日志中我得到

2017-07-11T07:55:54.593Z I status: The entire people list: [object Object]

Eventually I want to send the object back to the mobile device but I want to make sure I see the data inside.最终我想将对象发送回移动设备,但我想确保我能看到里面的数据。 Ideas?想法?

Thanks Eran谢谢伊兰

I had similar issue.我有类似的问题。 I had to print it without string concatenation:我不得不在没有字符串连接的情况下打印它:

console.log("The entire people list:");
console.log(people);

This works for me:这对我有用:

console.log("The entire people list:", JSON.stringify(people));

just console.log snap.val() to see the response.只需console.log snap.val()即可查看响应。 Add if(snap.val().whateverProperty logic.添加if(snap.val().whateverProperty逻辑。

Firebase 功能:无法设置 # 的属性配置<object>只有一个吸气剂<div id="text_translate"><p> Firebase 功能运行良好我更新到最新的 firebase-tools 现在运行 firebase 服务时遇到此错误问题。</p><pre> [debug] [2020-05-28T20:37:11.387Z] [runtime-status] [93658] Error in handleMessage: => TypeError: Cannot set property config of #<Object> which has only a getter: TypeError: Cannot set property config of #<Object> which has only a getter at {....}/node/v10.15.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:455:19 at Generator.next (<anonymous>) at fulfilled ({....}/node/v10.15.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:5:58) [warn] ⚠ functions: Cannot set property config of #<Object> which has only a getter {"metadata":{"emulator":{"name":"functions"},"message":"Cannot set property config of #<Object> which has only a getter"}} [warn] ⚠ Your function was killed because it raised an unhandled error. {"metadata":{"emulator":{"name":"functions"},"message":"Your function was killed because it raised an unhandled error."}}</pre></div></object> - Firebase functions : Cannot set property config of #<Object> which has only a getter

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase:如何从数组字段中获取数据并在控制台中打印? - Firebase: How to fetch data from an array field and print it in console? Firebase Cloud Functions - 如何调用另一个函数并返回对象 - Firebase Cloud Functions - How to call another function and return object Firebase 函数:SignatureDoesNotMatch - Firebase Functions : SignatureDoesNotMatch Cloud Functions for Firebase 超时 - Cloud Functions for Firebase timeout Firebase 函数 onRequest 到 onCall - Firebase functions onRequest to onCall Firebase 功能:无法设置 # 的属性配置<object>只有一个吸气剂<div id="text_translate"><p> Firebase 功能运行良好我更新到最新的 firebase-tools 现在运行 firebase 服务时遇到此错误问题。</p><pre> [debug] [2020-05-28T20:37:11.387Z] [runtime-status] [93658] Error in handleMessage: => TypeError: Cannot set property config of #<Object> which has only a getter: TypeError: Cannot set property config of #<Object> which has only a getter at {....}/node/v10.15.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:455:19 at Generator.next (<anonymous>) at fulfilled ({....}/node/v10.15.0/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:5:58) [warn] ⚠ functions: Cannot set property config of #<Object> which has only a getter {"metadata":{"emulator":{"name":"functions"},"message":"Cannot set property config of #<Object> which has only a getter"}} [warn] ⚠ Your function was killed because it raised an unhandled error. {"metadata":{"emulator":{"name":"functions"},"message":"Your function was killed because it raised an unhandled error."}}</pre></div></object> - Firebase functions : Cannot set property config of #<Object> which has only a getter 预定 Firebase 功能 - Scheduled Firebase Functions Firebase 函数未被调用 - Firebase functions not being invoked 我是否需要在 firebase 云函数的 context.auth object 上使用 verifyIdToken? - Do I need to use verifyIdToken on the context.auth object in firebase cloud functions? 在 firebase 云功能中具有 typescript 的 firebase-admin - firebase-admin with typescript in firebase cloud functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM