Property 'toPromise' does not exist on type 'Observable'

后端 未结 3 1105
死守一世寂寞
死守一世寂寞 2020-12-02 21:58
import { Headers, Http } from \'@angular/http\';

@Injectable()
export class PublisherService{

    private publishersUrl =          


        
相关标签:
3条回答
  • 2020-12-02 22:22

    Try adding 'Response' to your import statement from '@angular/http' like this :

    import {Http, Headers, Response} from '@angular/http';
    

    Also i noticed you don't import Ingectable from angular core although you use @Injectable decorator.

    import { Injectable } from '@angular/core';
    
    0 讨论(0)
  • 2020-12-02 22:30

    use this import at the beginning

    import {Observable} from "rxjs/Rx";
    
    0 讨论(0)
  • 2020-12-02 22:39

    You need to add the operator like this:

    import 'rxjs/add/operator/toPromise';
    

    This is needed for every rxjs operator you want to use.

    0 讨论(0)
提交回复
热议问题