0

I am import a firebase at the top of my /buildings.vue component:

...
import buildingsadd, { buildingsRef } from './buildingsadd.vue';


export default {
  firebase() { 
    return { 
    buildings: buildingsRef
    }
  },
  components: {
    buildingsadd
  },
  name: 'buildings',
  ...

On the the /buildingsadd.vue component I am defining a new path to the the firebase ref like this:

...
import firebase from '../firebase-config';
import { db } from '../firebase-config';
export default {
  firebase() { 
    return {
    buildings:  buildingsRef,
    users: usersRef,
    }
  },
  name: 'buildingsadd',
  data () {
    return {
      newBuilding: {
        name: '',
      } 
    }
  },
  methods: {
    addBuilding: function () {
      let userId = firebase.auth().currentUser.uid;
      let buildingsRef = db.ref('buildings/'+userId);
    }
...

But I am getting this errors:

enter image description here any ideas?

Answers to this would also solve my particular problem:

1 Answers1

0

You are not exporting buildingsRef. Export it like below.

buildingsadd.vue:

import firebase from '../firebase-config';
import { db } from '../firebase-config';

let userId = firebase.auth().currentUser.uid;                  // added
export let buildingsRef = db.ref('buildings/'+userId);         // added

export default {
  // ... (all the same)
  methods: {
    addBuilding: function () {
                                                               // removed lines here
    }
...
acdcjunior
  • 132,397
  • 37
  • 331
  • 304
  • I see in https://stackoverflow.com/questions/49760478/how-to-get-the-user-info-to-the-data-part-of-the-app-in-vue-js you are importing `buildingsRef` from `'../firebase-config'`. So you ended up using this method, but in a different file, yes? – acdcjunior Apr 10 '18 at 22:40