Firebase 在屏幕上显示Json对象数组

Firebase 在屏幕上显示Json对象数组,firebase,google-cloud-functions,Firebase,Google Cloud Functions,我已成功地查询并将数据收集到包含多个Json对象的数组中 但我的问题是,当我运行云函数URL时,如何在屏幕上显示该数组 这是我的代码 let returnArr = []; ... ... ... let result:PendingTransaction = { powerpalUser_id: userID, transaction_id: fn.key,

我已成功地查询并将数据收集到包含多个Json对象的数组中

但我的问题是,当我运行云函数URL时,如何在屏幕上显示该数组

这是我的代码

let returnArr = [];
...
...
...

let result:PendingTransaction = {
                               powerpalUser_id: userID,
                               transaction_id: fn.key,
                               transaction_points: rewardTransaction.transaction_points,
                               transaction_status: rewardTransaction.transaction_status,
                               transaction_date: rewardTransaction.transaction_date,
                               transaction_recipient: rewardTransaction.transaction_recipient
                           };

 returnArr.push(result);

 response.status(200).json(returnArr);
您可以执行以下操作:

在Cloud函数中,返回
returnArr
,如下所示:

response.status(200).send(returnArr);
在您的网页中,您将获得一个JavaScript对象,其中数组
returnArr
将位于该对象的
data
属性中

下面是一个web页面示例,它调用Cloud函数并在控制台中使用JavaScript打印数组项的一些值

您可以在此JavaScript中执行任何需要的操作,例如:填充表格、为每个项目创建div并写入内容、填充下拉框等

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SO example</title>

    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

</head>
<body>

<script>

    axios.get('https://us-central1-myprojectname.cloudfunctions.net/date')
        .then(function (response) {

            results = response.data;  // Array

            for (var key in results) {
                if (results.hasOwnProperty(key)) {
                    // Here use the results object as you wish with results[key].property, as illustrated below with the console.log()
                    console.log(key + " -> " + results[key].powerpalUser_id + " - " + results[key].transaction_points  + " - " + results[key].transaction_status);
                }
            }

        })
        .catch(function (error) {
            console.log(error);
        });


</script>

</body>
</html>

以身作则
axios.get()https://us-central1-myprojectname.cloudfunctions.net/date')
.然后(功能(响应){
结果=response.data;//数组
用于(var输入结果){
if(results.hasOwnProperty(key)){
//在这里,可以根据需要将results对象与results[key].property一起使用,如下面的console.log()所示
console.log(key+“->”+结果[key]。powerpalUser\u id+“-”+结果[key]。事务点+“-”+结果[key]。事务状态);
}
}
})
.catch(函数(错误){
console.log(错误);
});

请注意,我使用Axios库调用HTTPS云函数,但当然,您可以使用任何其他适合您需要的方法。

您的前端技术是什么?Web/Android/iOS/?您希望如何显示此阵列。在一张桌子里?这是网络。我只需要将JSON对象返回到数组中。。。