Angularfire: Property 'do' does not exist on type 'FirebaseListObservable<any[]>'

Created on 20 May 2016  路  7Comments  路  Source: angular/angularfire

Hello guys,

I'm following the doc here but I got this error Property 'do' does not exist on type 'FirebaseListObservable<any[]>' when trying to run the "Retrieving the snapshot" code. My code is mostly the same with the one in tutorial.

var items = this.af.database.list('/organizations', { preserveSnapshot: true });
items
      .do(snapshots => {
            snapshots.forEach(snapshot => console.log(snapshot.key()));
      })
     .subscribe(snapshots => console.log(snapshots.length));

My angularfire2 version is 2.0.0-beta.0. NodeJS version is 4.4.4.

Thank you.

Most helpful comment

@ngocnb-2nf

import 'rxjs/add/operator/do';

Adding this at the top solved the issue for me.

All 7 comments

Hey @ngocnb-2nf. What do your imports look like? You may have to import the do operator from rxjs.

Hi @davideast, below is my import:

import { Injectable, Inject } from '@angular/core';
import { FirebaseRef, AngularFire } from 'angularfire2';

I read file utils/firebase_list_factory.ts and see the import below:

import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/map';

There's no operator do here. I tried to add it manually but got not luck :).

@ngocnb-2nf

Can you create a plnkr? This is usually a problem with the import statement.

@ngocnb-2nf

import 'rxjs/add/operator/do';

Adding this at the top solved the issue for me.

Thanks, @UzairNouman!

In my case I have
import 'rxjs/add/operator/do';
get the same error
here is my code

getFamilyType(): Observable<IFamilyType[]> {
    return this._http.get<IFamilyType[]>(this._familyTypeUrl)
    .do(data => console.log('All: ' + JSON.stringify(data)))
    .catch(this.handleError);
}

@TorajKhavari That might be because of the recent changes in RxJS, try the following:

import {tap} from "rxjs/operators"; // I believe tap replaces do now, gotta confirm

Also, now to use those operators, you need to use the pipe() for chaining like:
.pipe(tap(data => console.log('All: ' + JSON.stringify(data))))

This link should give you a good summary of the changes that appeared in RxJS 6:
https://auth0.com/blog/whats-new-in-rxjs-6/

Hope that helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

itisparas picture itisparas  路  3Comments

KLiFF2606 picture KLiFF2606  路  3Comments

StephenFluin picture StephenFluin  路  3Comments

jteplitz picture jteplitz  路  3Comments

Maistho picture Maistho  路  3Comments