exports.setupDefaultPullups = functions.auth.user()
.onCreate(
async (user) => {
const dbRef= functions.database.ref;
let vl= await (dbRef.once('value').then( (snapshot) => {
return snapshot.ref.child('userInfo/'+user.uid).set(18);
}));
return vl;
}
);
I have been working on creating a trigger to initialize settings for new users in Firebase. Unfortunately, the code above is not functioning as expected. Can anyone identify what might be causing this issue? Essentially, when a new user registers, I want to automatically set their "defaultPullUps" property to 18 using the specified path.
UPDATE: Apologies for the lack of detail initially. The problem with the "async" keyword has been resolved by updating the node.js engine. However, I am encountering different error messages depending on how I modify the code. At times, it indicates that "... is not a function".
UPDATE': Despite acknowledging the shortcomings of my question, there is valuable information within it: the online documentation for Firebase authentication triggers lacks guidance on accessing the "main" database https://firebase.google.com/docs/functions/auth-events
UPDATE'': Below is the full error message:
TypeError: Cannot read property 'child' of undefined
at exports.setupDefaultPullups.functions.auth.user.onCreate.user (/srv/index.js:15:36)
at cloudFunctionNewSignature (/srv/node_modules/firebase-functions/lib/cloud-functions.js:105:23)
at /worker/worker.js:756:24
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)