Skip to content

TypeError: admin.auth(...).getUserByPhoneNumber is not a function #100

@cappittall

Description

@cappittall

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions