-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Description
Here the code at index.js (briefly)
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
const dB = admin.database();
`exports.contactAdded = functions.database.ref('/cards/{userPhoneEmail}/cont')
.onWrite(event =>{
var telMail = (event.data._path).split('/')[2];
if (!telMail.includes('@')) {
admin.auth().getUserByPhoneNumber(telMail)
.then(function(userRecord) {
console.log("Successfully fetched user data:", userRecord.toJSON());
findOutMyContacts(userRecord);
})
.catch(function(error) {
console.log("Error fetching user data:", error);
});
}
return console.log(event.data._path, event.data._delta, event.data._newData);
});`
Function is triggered but this : admin.auth().getUserByPhoneNumber(telMail) gives an error :
TypeError: admin.auth(...).getUserByPhoneNumber is not a function
at exports.contactAdded.functions.database.ref.onWrite.event (/user_code/index.js:234:22)
at /user_code/node_modules/firebase-functions/lib/cloud-functions.js:35:20
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
Metadata
Metadata
Assignees
Labels
No labels