L
L
Lev Vorobyov2020-02-22 23:55:24
Vue.js
Lev Vorobyov, 2020-02-22 23:55:24

How to access a variable from another file?

There is a config.js file for storing connection settings to Firebase:

export default {
    data: () => ({
        firebaseData: {
            // тут объект с настройками
        }
    }),
    methods: {
        getDBData() {
            return this.firebaseData
        }
    }
}

and there is a file at the same level main.js
import config from './config'
import firebase from 'firebase/app'

firebase.initializeApp(config.methods.getDBData());

but
config.methods.getDBData()
returns undefined in console.log(), how then to take data from data()?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2020-02-22
@thylaakari

Move only the object with the settings to a separate file. And then import it where needed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question