0

I'm trying to create a simple Firebase function using Firebase Auth that returns a user's uid if I send it a valid email address. No matter what I change I always get the same error:

Error fetching user data: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received type function ([Function (anonymous)])

To call it I use: ...cloudfunctions.net/[email protected]
I have tried wyn%40wyn.com as well. The user does exist.

enter image description here

I'm obviously doing something wrong. But what?

 export const checkemail = functions .region("deleted") .https.onRequest(async (request, response) =>{ const email = String(request.query.email); await admin.auth().getUserByEmail(email) .then((userRecord)=> { const data = userRecord.toJSON; response.send(data); }) .catch(function(error) { response.send("Error fetching user data: "+ error); }); }); 

1 Answer 1

2

toJSON is a method. Therefore it needs brackets: const data = userRecord.toJSON()

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.