I am trying to create a very simple angular service:
import { Http, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
export class Webservice {
constructor(private http: Http) {
}
getMessages() {
return this.http.get('http://localhost:63962/api/someshittyendpoint').toPromise();
}
}
Whatever I do, I get the following Module not found: Error: Can't resolve 'rxjs/add/operator/toPromise'
.
I have installed rxjs-compat and verified that the module actually is on the path. I don't understand what's wrong?
Thanks in advance!
toPromise
is not an operator. It's a method on the Observable
class which means you don't have to import it:
See the source code: https://github.com/ReactiveX/rxjs/blob/5.5.11/src/Observable.ts#L332-L354
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments