itsource

Firebase Error:함수 쿼리여기서()이 유효하지 않은 데이터로 호출되었습니다.지원되지 않는 필드 값: 정의되지 않음

mycopycode 2022. 9. 4. 21:37
반응형

Firebase Error:함수 쿼리여기서()이 유효하지 않은 데이터로 호출되었습니다.지원되지 않는 필드 값: 정의되지 않음

어디서 특정된 서류만 받고 싶습니다.

uid 속성에 등록된 이메일 주소를 신규 등록 시 Firestore에 값으로 저장합니다.

    async signUp() {
      const db = firebase.firestore();
      await this.$store.dispatch('signUp', { username:this.username, email:this.email, password:this.password });
      await db.collection('myData').doc(this.username).set({
        uid: this.email,
        email: this.email,
        myWallet: 1000
      });
      this.$router.push('/home');
    }
async signUp({ commit }, userInfomation) {
      try {
        await firebase
          .auth()
          .createUserWithEmailAndPassword(
            userInfomation.email,
            userInfomation.password
          );
        const user = firebase.auth().currentUser;
        await user.updateProfile({
          displayName: userInfomation.username,
        });
        commit('setUserName', user);
      } catch (e) {
        alert(e.message);
      }
    },
  mutations: {
    setUserName(state, user) {
      state.userName = user.displayName;
    },
actions: {
async getMyWallet({ commit, state }) {
      const uid = state.updateUserName.email; //Information on the logged-in user is stored in updateUserName.
      const db = firebase.firestore();
      const doc = await db
        .collection('myData')
        .where('uid', '==', uid)
        .get();
      commit('getMyWallet', doc);
    }
}

실행했을 때 제목에 오류가 표시되었습니다.

잘못 쓴 건가요?

다른 좋은 방법이 없을까요?

    async getMyWallet({ commit }) {
      firebase.auth().onAuthStateChanged(user => {
        const uid = user.email;
        const db = firebase.firestore();
        const doc = db
          .collection('myData')
          .where('uid', '==', uid)
          .get();
        commit('getMyWallet', doc);
      });
    },

get My Wallet 부분을 다시 작성했을 때 새로운 오류가 발생하였습니다.

오류 상세: doc.data가 함수가 아닙니다.

언급URL : https://stackoverflow.com/questions/66351792/firebaseerror-function-query-where-called-with-invalid-data-unsupported-fiel

반응형