文書化された機能が動作していないように思われるこの奇妙な問題が見つかりました。once()が完全に動作している間にadmin.ref.on()が動作しない
私はこの作業コードを持っている:私はonce()
からon()
に変更すると
exports.getEvents = functions.https.onRequest((req, res) => {
cors(req, res,() => {
admin.database().ref('events').orderByValue().once('value', function(snapshot) {
res.status(200).send(snapshot.val());
}).catch(error => {
console.error('Error while reading data', error);
res.status(403).send('Error: ' + error);
});
は、私はエラーを取得します。
を直接読み取るアプリがあるので、events
に変更があったときにサーバーが新しいJSONペイロードを送信し、データを提供するためのリンクしか使用できないため、すべてのSDK機能が無効になります。私は何か間違っているのですか?
エラーログ:
TypeError: admin.database(...).ref(...).orderByValue(...).on(...).catch is not a function
at cors (/user_code/index.js:24:11)
at cors (/user_code/node_modules/cors/lib/index.js:188:7)
at /user_code/node_modules/cors/lib/index.js:224:17
at originCallback (/user_code/node_modules/cors/lib/index.js:214:15)
at /user_code/node_modules/cors/lib/index.js:219:13
at optionsCallback (/user_code/node_modules/cors/lib/index.js:199:9)
at corsMiddleware (/user_code/node_modules/cors/lib/index.js:204:7)
at exports.getEvents.functions.https.onRequest (/user_code/index.js:19:2)
at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:26:47)
at /var/tmp/worker/worker.js:635:7
どのようなエラーがありますか?セキュリティルールとサンプルデータを共有できますか? – Kato
'once()'メソッドが完全に機能するので、セキュリティとは関係ありません。ダッシュボードからエラーログを使用して質問を更新しました。おそらくそれが役に立ちます。 –