Я могу успешно получить параметр запроса и отправить его в свою базу данных в реальном времени по пути, определенному самим параметром запроса, используя этот код:
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.emptyHat = functions.https.onRequest(async (req, res) => {
// Grab the group parameter.
const group = req.query.group;
// Push the new message into the Realtime Database using the Firebase Admin SDK.
const snapshot = await admin.database().ref('/group').push({list: group});
// Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
res.redirect(303, snapshot.ref.toString());
});
Если параметром запроса было 'test', результатом будет новая запись в / test / {firebaseID} / {'list': 'test'}
Когда я попытался изменить его, чтобы удалить узел, указанный в параметре запроса Я получаю ошибки. (Я пытаюсь удалить этот верхний уровень / test node
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.emptyHat = functions.https.onRequest(async (req, res) => {
// Grab the group parameter.
const group = req.query.group;
// Remove the node at the location 'group'.
functions.database().ref('/group').remove();
// Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
//res.redirect(303, snapshot.ref.toString());
});
Сообщение об ошибке в журналах:
at exports.emptyHat.functions.https.onRequest (/srv/index.js:95:13)
at cloudFunction (/srv/node_modules/firebase-functions/lib/providers/https.js:49:9)
at /worker/worker.js:783:7
at /worker/worker.js:766:11
at _combinedTickCallback (internal/process/next_tick.js:132:7)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)