I need to put data from previous promise result to the next promise result.
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()?
});
In first then
I get results from firebase database with promise and make request for get data about subscriptions for user_uid
, and put result of this request into promise
. But how to linked user_uid
with promise
?