【发布时间】:2021-11-02 10:19:15
【问题描述】:
所以我使用 Firebase 实时数据库来存储一些数据,并希望使用查询结果作为另一个函数的输入(生成签名 URL)。我的代码如下:
// initialize the empty list
let lista = []
// define the async function that does everything
async function queryandgeturls() {
// make the query to the firebase realtimeDB
await ref.orderByChild('timestamp_start').startAt(timestamp1).endAt(timestamp2).on('child_added', (snapshot) => {
lista.push(snapshot.val().name);
});
// use the list as input for another function to get Signed URLs
for (const fileName of lista) {
const [signedUrl] = await storage.bucket(bucketName).file(fileName).getSignedUrl({
version: 'v4',
expires: Date.now() + 15 * 60 * 1000,
action: 'read'
});
console.log(`The signed URL for ${fileName} is ${signedUrl}`);
}
};
// call the function
queryandgeturls().catch(console.error);
到目前为止没有运气。有什么线索吗?
【问题讨论】:
-
你想在哪里使用它们?您可以简单地从那里调用第二个函数并将它们作为参数传递?
标签: node.js firebase-realtime-database firebase-admin