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.
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); }); }); 