'Property 'user' does not exist on type 'void'.ts(2339)
I am trying to create singup form with firebase i am following this video and now i have this error i dont know what is problem and how to fix it
This is my auth.service.ts file
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { GoogleAuthProvider } from 'firebase/auth';
import { AngularFirestore, AngularFirestoreDocument } from '@angular/fire/compat/firestore';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { Observable, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { user } from './user.models';
@Injectable({
providedIn: 'root'
})
export class AuthService {
user$: Observable<user | null | undefined>;
constructor(
private afauth: AngularFireAuth,
private router: Router,
private afs: AngularFirestore
) {
this.user$ = this.afauth.authState.pipe(
switchMap(user => {
if(user){
return this.afs.doc<user>('users/${user.uid}').valueChanges()
}else{
return of(null)
}
})
);
}
async googleSignin(){
const provider = new GoogleAuthProvider()
const credential = await this.afauth.signInWithRedirect(provider)
return this.updateUserData(credential.user); // ERROR IS HERE
}
updateUserData(user: any){
const userRef: AngularFirestoreDocument<user> = this.afs.doc('users/${user.uid}');
const data = {
uid: user.uid,
email: user.email,
displayName: user.displayName,
name: user.name
};
return userRef.set(data, {merge: true})
}
async signOut(){
await this.afauth.signOut()
return this.router.navigate(['/']);
}
}
I am using latest angular and firebase with node I really dont know about this method i use functions.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
