nuxtのssrを使用しており、個別のvueファイルのmountedメソッド内で都度取得するのではなく、アプリケーションにアクセスされた際にユーザ情報を取得し、存在していれば、storeで保持させたいです。
下記のように実装しましたが、userの中身はNULLでした。
解決方法や別の良い実装方法がございましたら、教えていただけないでしょうか。
~/plugins/firebase
import firebase from 'firebase' if (!firebase.apps.length) { firebase.initializeApp({ apiKey: "xxxxx", authDomain: "xxxxx", databaseURL: "xxxxx", projectId: "xxxxx", torageBucket: "xxxxx", messagingSenderId: "xxxxx" }) } export default firebase
store/user/Login
export const actions = { async load({ commit, state }) { await firebase.auth().onAuthStateChanged(user => { console.log('load', user) ←NULLになる }) } }
store/index.js
export const actions = { async nuxtServerInit({ dispatch, commit }, { req }) { await dispatch('user/Login/load') } }
バージョン
"nuxt": "^2.4.0",
"firebase": "^6.0.4"
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。