я получаю эту ошибку в своем коде Nodejs бэкэнда Firebase "Функция вернула неопределенное, ожидаемое обещание или значение" Вот код, который выполняется;
exports.payOnDelivery = functions.database.ref('/CompletedJobs/{id}').onCreate((snapshot, context) => {
let chargeID = snapshot.child("chargeID/id").val();
let amount = +(snapshot.child("chargeID/amount").val());
let amountAfterCut = amount*0.75;
let emailHash = snapshot.child("jobTaker").val();
if (chargeID == null || amount == null || emailHash == null){
console.log("Could not parse data");
return 1;
}
console.log("This is Before Observe");
console.log('Blah blah:', chargeID, amount, emailHash);
admin.database().ref(`Couriers/${emailHash}`).once('value').then(function(userSnapshot){
const accountID = userSnapshot.child("stripeAccount/id");
console.log("AcctID:",accountID);
stripe.transfers.create({
amount: amountAfterCut,
currency: "cad",
source_transaction: chargeID,
destination: accountID
}), function(err, transfer){
if (err){
console.log(err);
return 1;
}
else{
console.log("Transfer made",transfer);
return 0;
}
}
}, function(error){
console.error(error);
});
});
Любая помощь действительно приветствуется.Спасибо.