如何在Reactjs中将Firebase存储添加到预先存在的Firebase初始化程序中

时间:2019-06-23 15:24:34

标签: reactjs firebase firebase-storage

我正在尝试将firebase-storage集成到我的firebase类中,但是我不知道该怎么做

我尝试创建一个专门用于存储的单独的初始化程序,并将其添加到firebase类之外

import app from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';
import 'firebase/storage';

const config = { ... }

class Firebase {
  constructor() {
    app.initializeApp(config);

    /* Firebase APIs */

    this.auth = app.auth();
    this.db = app.database();
  }

    // *** Auth API ***

    doCreateUserWithEmailAndPassword = (email, password) =>
       this.auth.createUserWithEmailAndPassword(email, password);

    doSignInWithEmailAndPassword = (email, password) =>
       this.auth.signInWithEmailAndPassword(email, password);

    doSignOut = () => this.auth.signOut();

    // *** User API ***

    user = uid => this.db.ref(`users/${uid}`);

    users = () => this.db.ref('users');
}

0 个答案:

没有答案