Cannot find the '@angular/common/http' module

后端 未结 9 1379
被撕碎了的回忆
被撕碎了的回忆 2020-12-01 04:25

I am following this fundamental tutorial on Angular about Http.

As one can see in the \"Setup: Installing the module\" section, they import the HttpClientModule as f

9条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 04:39

    You should import http from @angular/http in your service:

    import {Http} from '@angular/http';
    
    constructor(private http: http) {} // <--Then Inject it here
    
    
    // now you can use it in any function eg:
    getUsers() {
        return this.http.get('whateverURL');
    }
    

提交回复
热议问题