gpt4 book ai didi

javascript - 将先前 promise 中的数据放入新 promise 中

转载 作者:搜寻专家 更新时间:2023-10-31 23:23:19 25 4
gpt4 key购买 nike

<分区>

我需要将上一个 promise 结果的数据放到下一个 promise 结果中。

var database = admin.database().ref('/schema-v0_1/objects/subscription');
return database.once("value").then(function(snapshot) {
var array_user_subs = [];
snapshot.forEach(function(data) {
var user_uid = data.key;
var database_user_subs = admin.database().ref('/schema-v0_1/objects/subscription');
var promise = database_user_subs.child(user_uid).once("value", function(snapshot) {
}, function(error) {
});
array_user_subs.push(promise);
});
return Promise.all(array_user_subs);
}).then(function(array_user_subs) {
var array_subs_info = [];
array_user_subs.forEach(function(data) {
var user_uid = data.key;

data.forEach(function(snapshot) {
var gpa = snapshot.key;
var token_purchase = snapshot.val().token;
var sku_purchase = snapshot.val().sku;

var promise = promisify(publisher.purchases.subscriptions.get)({
packageName: 'com.example',
subscriptionId: sku_purchase,
token: token_purchase
});

//how to linked user_uid with promise?
array_subs_info.push(promise);
});
}
return Promise.all(array_subs_info);
}).then(function(array_subs_info) {
//here I get array with results of promise, but how to get linked with result user_uid from previous promise in previous then()?
});

首先 然后 我从 firebase 数据库中获得了 promise 的结果,并请求获取有关 user_uid 订阅的数据,并将此请求的结果放入 promise 。但是如何将 user_uidpromise 联系起来呢?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com