Skip to content Skip to sidebar Skip to footer

Firebase Cloud Functions: How To Push Data Using Wildcards In Http Requests

I'm exploring new Cloud Functions feature in Firebase, so I know how wildcards work in Realtime database triggers, but when I'm trying to add wildcards in http request, it ignores

Solution 1:

The syntax for wiring up a wild-card in a trigger, does not apply for building a path to a database reference. There you'll have to use regular string interpolation:

exports.addEntry = functions.https.onRequest((req, res) => {
  const value = req.query.addValue;
  admin.database().ref('users/'+userId).push({value}).then(snapshot => {
  res.redirect(303, snapshot.ref); });
});

Or ES6 template literals:

exports.addEntry = functions.https.onRequest((req, res) => {
  const value = req.query.addValue;
  admin.database().ref(`users/${userId}`).push({value}).then(snapshot => {
  res.redirect(303, snapshot.ref); });
});

Post a Comment for "Firebase Cloud Functions: How To Push Data Using Wildcards In Http Requests"