How can save my user to Firebase Auth


#1

Greetings!

In the script editor I have tried to add a piece of code to create a new user as part of a registration process, but I am unable to use firebase there, even though firebase plugin can be used on other parts of my app.

In one of the screenshots that shows how to use the script editor it shows the following:

const db = firebase.firestore();

I have tried to use it, but the compiler doesn’t like it, so I tried importing firebase, below is my code:

import firebase from ‘firebase’;

const db = firebase.firestore();

let userData = db
.auth()
.createUserWithEmailAndPassword(this.state.field_email, this.state.field_password)
.then((response) => {
const uid = response.user.uid
const userData = {
id: uid,
email: this.state.field_email,
fullName: this.state.field_name
};
return userData
})
.catch(error => alert(error))

Please assist.

Regards,
Mike