第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

firebase/firestore 將用戶保存到集合

firebase/firestore 將用戶保存到集合

皈依舞 2022-10-13 19:29:29
我正在嘗試將用戶保存到我的 Firestore 中的集合中。似乎正在創(chuàng)建用戶,我可以在Authentication選項卡中看到它們,但是它們沒有保存到我的 Firestore 內(nèi)的收藏中。我的控制臺內(nèi)似乎也沒有任何錯誤。我已經(jīng)為此苦苦掙扎了幾個小時,我什至不知道如何調(diào)試它。export const authMethods = {  signup: (email, password, setErrors, setToken) => {    firebase      .auth()      .createUserWithEmailAndPassword(email, password)      // make res asynchronous so that we can make grab the token before saving it.      .then(async res => {        const token = await Object.entries(res.user)[5][1].b        // set token to localStorage        await localStorage.setItem('token', token)        // grab token from local storage and set to state.        setToken(window.localStorage.token)        const userUid = firebase.auth().currentUser.uid        const db = firebase.firestore()        db.collection('/users')          .doc(userUid)          .set({            email,            password,          })        console.log(res)      })      .catch(err => {        setErrors(prev => [...prev, err.message])      })  }, ....}有任何想法嗎?
查看完整描述

1 回答

?
肥皂起泡泡

TA貢獻1829條經(jīng)驗 獲得超6個贊

await從中刪除localStorage.setItem不是異步函數(shù)。


您還需要將 await 添加到db.collection("/users").doc(userUid)


這是您可以做的另一種方法。讓云功能為您處理。


每當創(chuàng)建用戶時,都會觸發(fā)以下功能。


export const onUserCreate = functions.auth

  .user()

  .onCreate(async (user, context) => {

    await admin.firestore().collection("users").doc(user.uid).set({

      id: user.uid,

      emailAddress: user.email,

      verified: user.emailVerified,

    });

  });

如果您需要有關(guān)云功能的更多信息,請閱讀以下內(nèi)容。


https://firebase.google.com/docs/functions/get-started


查看完整回答
反對 回復(fù) 2022-10-13
  • 1 回答
  • 0 關(guān)注
  • 110 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號