I have been learning how to go about firebase cloud functions and have slowly understood how the HTTPS requests work, however I'm stuck on retrieving data for the users email.
I want to check if the specific email that they enter in the app is already taken in my firebase project, I was going to do it on the client side but learnt that its more secure if I do it through cloud functions.
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
import { response } from 'express';
admin.initializeApp()
export const getEmail = functions.https.onRequest((request, response) => {
admin.auth().getUserByEmail(email)
.then(snapshot => {
const data = snapshot.data()
response.send(data)
})
.catch(error => {
//Handle error
console.log(error)
response.status(500).send(error)
})
})
I keep on receiving an error that the data object does not exist on type 'userRecord'.
Error message (update): Property 'data' does not exist on type 'UserRecord'