TIL 01.25

새양말·2023년 1월 25일
0

내일배움캠프TIL

목록 보기
55/74
post-thumbnail

오늘 파이어베이스로 로그인하는 부분에서 에러가 났다.
회원가입을 할 때 쓰이는 생성함수에 닉네임이 없는데
user객체 정보에 displayname있는 걸 보고 넣어본 것이 에러 원인이었다.

회원가입 단계에서 넣고싶다면 updateProfile()를 해주어야 한다.

await createUserWithEmailAndPassword(authService, email, password)
      .then(() => {
        console.log('회원가입 성공!');
        updateProfile(authService.currentUser, {
          displayName: nickName,
        })
          .then(() => {
            alert('회원가입 성공!');
            setEmail('');
            setNickName('');
            setPassword('');
            navigate('/');
          })
          .catch((error) => {
            console.log(error.message);
          });
      })
      .catch((error) => {
        console.log(error.message);
        if (error.message.includes('already-in-use')) {
          alert('이미 사용중인 아이디입니다.');
        }
      });
profile
매번 기합넣는 양말

0개의 댓글