0

I'm trying to get the database from Firebase. I have walked through this tutorial. After I run ng serve nothing happened and I have this error in the console:

[2018-05-21T12:25:48.364Z] @firebase/firestore: Firestore (5.0.3): Could not reach Firestore backend.

environment.ts:

export const environment = {
  production: false,
  firebase: {
    apiKey: "AIzaSyCip0O3rjU6AXHUKZg7Z26hpLZThTfStsA",
    authDomain: "clientpanel-c4a89.firebaseapp.com",
    databaseURL: "https://clientpanel-c4a89.firebaseio.com",
    projectId: "clientpanel-c4a89",
    storageBucket: "clientpanel-c4a89.appspot.com",
    messagingSenderId: "894070096713"
  }
};

app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

// FIREBASE / ANGULARFIER2
import { environment } from '../environments/environment';
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';
import { AngularFireStorageModule } from 'angularfire2/storage';
import { AngularFireAuthModule } from 'angularfire2/auth';

// COMPONENTS
import { AppComponent } from './app.component';


@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFirestoreModule,
    AngularFireStorageModule,
    AngularFireAuthModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts:

import { Component } from '@angular/core';
import { AngularFirestore } from 'angularfire2/firestore';
import { Observable } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css']
})
export class AppComponent {
  items: Observable<any[]>;
  constructor(db: AngularFirestore) {
    this.items = db.collection('/client').valueChanges();
  }
}

app.component.html:

<h2>The list</h2>

<ul>
  <li class="text" *ngFor="let item of items | async">
    {{item.email}}
  </li>
</ul>

And finally, This is My Firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Budi Salah
  • 153
  • 2
  • 11

1 Answers1

0

Your screenshot shows that you are using the firebase Real-time Database, but your code uses the firebase Cloud Firestore.

Change AngularFirestore to AngularFireDatabase.

Working example with your database: https://stackblitz.com/edit/so002

-OR-

Move your data to the Cloud Firestore

Tim Martens
  • 1,464
  • 9
  • 18