I started creating a web app with the firebase database. The firebase config is in a separate file that gets imported into the application.
Now I want to add firebase storage, but I can't seem to export both db and st. I get an error message saying that vuejs doesn't support named exports. I would export app instead and get rid of the db and st references, however my application already has tons of references to db. Is there a simple way to export db and st?
const app = Firebase.initializeApp(config);
const db = app.database();
const st = app.storage(); //this was recently added
export default db; //How do I add 'st' to the export in vuejs?
In order to achieve what you want,
you can export an object with db
and st
as properties, or export different variables.
this syntax is called ES6, which use modules. you can read more about them here (2ality blog) and here (MDN).
You can try:
export { db, st };
or
export const db = app.database();
export const st = app.storage();
Then, import them wherever you want.
import { db, st } from 'path/to/file'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With