如何使用response.json()函数从firebase数据库获取响应,而不是输出为response.json()不是函数

时间:2017-12-13 03:38:09

标签: angular

我试图从firebase中检索数据但是我在输出中得到的响应是response.json()不是函数..请帮助我..

src \ provider \ userservice.ts文件

     import { Injectable } from '@angular/core';
     import { User } from '../../models/userdata'
     import { Http } from '@angular/http';
     import { AuthService } from '../../providers/user/auth';
     import { Response } from '@angular/http/src/static_response';

     import 'rxjs/add/operator/map';
     //import { AngularFireDatabase, FirebaseListObservable } from 
     'angularfire2/database';


     @Injectable()

     export class UserServiceProvider {

     user: User[];

     constructor(private authservice: AuthService, private http: HttpClient) 
        {
         console.log('Hello UserProvider Provider');
        }

      fetchList(token: string)  {
        const userId = this.authservice.ActiveUser().uid;
        console.log('uid'+ userId);
         return this.http.get('https://recipe-book-ef34f.firebaseio.com/' + 
                                userId +
                               '/shopping-list.json?auth=' + token)  
      .map((response: Response) => {
       return response.json(); } )
      .do((user: User[]) => {
       if(user) {
       this.user = user;
       }
       });
     } 

0 个答案:

没有答案