Reputation:
I wrote a simple program with the angular framework to read values from a database, but when I ng serve the console gives the error 'firebase_app__WEBPACK_IMPORTED_MODULE_1__.database is not a function'
Here is the component in its entirety:
import {NgModule,Component} from '@angular/core'
import * as firebase from 'firebase/app'
import {firebaseConfig} from './firebaseConfig' // I put the credentials of my
// database in this file
@NgModule ({})
@Component({
selector: 'practiceFb',
template:``
})
export class practiceFb {
constructor () {
firebase.initializeApp(firebaseConfig);
var TheItem= firebase.database().ref('TheItem');
TheItem.on("value", (snapshot) => {
console.log(snapshot.val());
})
}
}
Upvotes: 0
Views: 213
Reputation: 7542
This is because you are importing from firebase/app
rather than just firebase
.
Try changing
import * as firebase from 'firebase/app';
to
import * as firebase from 'firebase';
Upvotes: 2