I found this example code in a tutorial:
getRandomQuote() {
this.http.get('http://localhost:3001/api/random-quote')
.map(res => res.text())
.subscribe(
data => this.randomQuote = data,
err => this.logError(err),
() => console.log('Random Quote Complete')
);
}
But when trying to use it, I only get TypeError: this.http.get(...).map is not a function in [null]
:
getChannels():Promise<Channel> {
return this.http.get('...')
.map(function (response:Response) {
...
}).toPromise();
}
My Typescript compiler tells me that those methods are avaible but when inspecting the return value of http.get()
they are missing.
I used the package.json of the current angualar2 starting guide:
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
...
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>
Any ideas what I might get wrong at this point?