1
Firebaseにリアルタイムデータベーストリガを使用するクラウド関数を作成しています。それはonWrite
を発生させ、次に私はPromises
を使って一連のコマンドを実行する必要があります。Firebase関数が必要です。プロンプトまたは値
私は1つの約束を使用するとコードを実行し、約束を連鎖させると信頼できなくなります。しかし、私は常にログにこれを取得する:必要な場所
Function returned undefined, expected Promise or value
私は値を返すいますし、まだ私は、このメッセージになってしまいました。私のコードは以下の通りです:
exports.sendQuotationToCustomer = functions.database.ref('/company/{companyId}/quotations/{quotationId}').onWrite((event) => {
const companyId = event.params.companyId;
console.log('Direct Generate');
const root = event.data.ref.root;
return root.child(`company/${companyId}/profile`).once('value')
.then((profileSnap) => {
console.log('1/Step');
const profile = profileSnap.val();
const docDefinition = helpers.createDocumentDefinition(profile, quotationData);
return docDefinition;
})
.then((result) => {
console.log('2/Step');
// Perform some manipulation over result. But meanwhile:
return result;
})
.catch((err) => {
console.log(`Failed with error info: ${err}`);
});
});
ここで間違っていますか?
正確に 'docDefinition'とは何ですか? –
こんにちは@DougStevenson、docDefinitionは私がステップ2で使用する予定のpdf生成用です。私はここにサンプルコードを書いています: 'https:// pastebin.com/Ubf10xqK' –
また、約束を繋ぐときに「信頼できなくなる」と言われたらどういう意味ですか?手順2で非同期作業を行っていますか? –