I’ve been trying to make register functions and store them in database in firebase even tho the users get created and they can successfully login and i see them in database i still get this error, makes no sense to me getting the error but still the users are getting created.
This is the typescript code
import { Component, OnInit } from '@angular/core';
import { Router } from "@angular/router";
import { AuthenticationService } from "../shared/authentication-service";
import {AlertController} from '@ionic/angular'
import {UserService} from '../user.service'
import {AngularFirestore} from '@angular/fire/firestore'
@Component({
selector: 'app-register',
templateUrl: './register.page.html',
styleUrls: ['./register.page.scss'],
})
export class RegisterPage implements OnInit {
constructor(
public authService: AuthenticationService,
public router: Router,
public alert: AlertController,
public user: UserService,
public afstore: AngularFirestore,
public alertController: AlertController
) { }
ngOnInit(){}
async presentAlert(title:string, content:string){
const alert = await this.alertController.create({
header: title,
message: content,
buttons: ["OK"]
})
await alert.present()
}
signUp(username, password){
this.authService.RegisterUser(username.value +'@gmail.com', password.value)
.then((res) => {
this.afstore.doc(`users/${res.user.uid}`).set({
username
})
this.user.setUser({
username,
uid: res.user.uid
})
this.presentAlert('Success', 'Register Complete')
this.router.navigate(['login']);
}).catch((error) => {
this.showAlert("Error", error.message)
})
}
async showAlert(header:string, message:string){
const alert = this.alert.create({
header,
message,
buttons:["Ok"]
})
await (await alert).present()
}
}
This is the error