vuejs vuex firebase

Asked

Viewed 59 times

0

with a problem to mount my next firebase reference

export default {
        firebase () {
            return {
                gastos: db.ref(`user/${this.uid}/shop/`), 
            }
        },
        computed: {
            uid () {
                return this.$store.getters.getUser.uid
            },
        }
    }

what happens is that here gastos: db.ref(1user/${this.uid}/shop/') mine this.uid not yet set in my store and does not mount my firebase reference

but if I use {{uid}} in the template ta ok, what I’m doing wrong?

  • 2

    Try to use in the Mounted method, I believe in the computed some things are not yet ready.

  • @narukaioh I appreciate the help, it did not work cmg pq I believe I have firebase assync error with vuex

1 answer

0

I believe you need to return a default value while you still don’t have the bank value, or augment the value arrive to display the page:

export default {
    firebase () {
        return {
            gastos: db.ref(`user/${this.uid}/shop/`), 
        }
    },
    computed: {
        uid () {
            const ret = (this.$store.getters.getUser & this.$store.getters.getUser.uid) ? this.$store.getters.getUser.uid : "valor-padrao";
            return ret;
        },
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.