const handleLoginWithEmail = async () => {
const user = await authService.signInWithEmail(
emailRef.current.value,
passwordRef.current.value,
);
console.info('logined user', user);
if (user == undefined) {
console.error('faild user response');
return;
}
changeLoginState(true);
};
async signInWithEmail(email: string, password: string) {
const auth = getAuth(firebaseApp);
signInWithEmailAndPassword(auth, email, password)
.then(userCredential => {
const user = userCredential.user;
return user;
})
.catch(error => {
const errorCode = error.code;
const errorMessage = error.message;
console.error(errorCode, errorMessage);
});
} //class authService
[2]에서 user에는 User라는 오브젝트가 저장됨 (authService 클래스에서 User가 정상적으로 리스폰스되는건 확인됨, User를 return하도록 했음)
근데 왜 [6]에서 로그 찍어보면 user가 undefined로 나올까?
return signInWithEmailAndPassword(auth, ... 로 바꿔
땡큐!!! 디버깅할때 꼭 알아둬야겠다