表題の通りです。
DBから値を取り出し、html側で表示したいと思っております。
こちらのページを参考にやっているのですが、下記のエラーが出てしまいます。
client.js:522 TypeError: WEBPACK_IMPORTED_MODULE_6__plugins_firebase.a.database(...).ref(...).child(...).val is not a function
at name (index.js:67) at wrappedGetter (vuex.esm.js:734) at Vue.computed.(anonymous function) (http://localhost:3000/_nuxt/vendor.js:89571:42) at Watcher.get (vue.runtime.esm.js:3138) at Watcher.evaluate (vue.runtime.esm.js:3245) at Vue.computedGetter [as name] (vue.runtime.esm.js:3503) at Object.get [as name] (vuex.esm.js:536) at VueComponent.mappedGetter (vuex.esm.js:852) at Watcher.get (vue.runtime.esm.js:3138) at Watcher.evaluate (vue.runtime.esm.js:3245)
今のコードはこれです。
Javascript
1async mounted () { 2 if (process.browser) { 3 let user 4 if (!this.user) user = await auth() 5 await Promise.all([ 6 this.user ? Promise.resolve() : this.$store.dispatch('setUser', { user: user || null }), 7 ]).then((user) => { 8 firebase.database().ref("users").once("value") 9 .then((snapshot => { 10 var name = snapshot.child(`${user.uid}/displayName`).val() 11 console.log(name) 12 })) 13 }) 14 this.isLoaded = true 15 } 16 },
FirebaseのDBでの階層構造は、
-users
. - uid
. - displayName
. email etc...
というようになっています。ご回答よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。