「Tour of Heroes」で実際の残りのAPIを使用して、angle2(PHPスクリプトから来て、それはかなり難しいです^^)を学ぼうとしています。私は、データを取得することができhero.service.tsでangular2:rest apiの問題
curl -XGET http://localhost:3001/heroes
[{"_id":"58185c8a8af4b512c51c0519","no":"1","name":"bahamut","__v":0,"updated_at":"2016-11-01T09:12:42.803Z"},{"_id":"58185ca78af4b512c51c051a","no":"2","name":"gatz","__v":0,"updated_at":"2016-11-01T09:13:11.063Z"},{"_id":"58185ec98af4b512c51c051b","no":"3","nam...
、::私が読んだものから は、私が働いて、API、Expressで構築されてきた
...それは単純なものと考えていたgetHeroes(): Promise<Hero[]> { // {{{
console.log('getheroes in service');
console.log("%o", this.http.get(this.heroesUrl).toPromise());
return this.http.get(this.heroesUrl)
.toPromise()
.then(response => response.json().data as Hero[])
.catch(this.handleError);
} // }}}
私はオリジナルの「英雄のツアー」で同じにconsole.logを行うと、ここで私は、文字列を持っているのに対し、私はデータの配列を持っている... 私は文字列をどこかに変換しなければならないと思うが、何を試しても動作しない。あなたはとても近くにいるJP
http:// localhost:3001/heroesはどのcontentTypeを応答しますか? – dfsq
あなたはJSON.parse(あなたの応答文字列>)と考えています – OliverRadini