I'm trying to load the following url into the example and it just won't return any data. I have changed the Hero class to match:
https://bedtimetunes.restlet.net/v1/tuneses/
export class Hero {
id: number;
title: string;
artist: string;
date: number;
likes: number;
plays: number;
contributors: string;
tags: string;
}
In my hero.service I have:
private headers = new Headers({"content-type": "application/json", "accept": "application/json", "host": "bedtimetunes.restlet.net"});
private heroesUrl = 'https://bedtimetunes.restlet.net/v1/tuneses/'; // URL to web api
The file is being properly loaded and I get the response 200 code, but I can't get it to display any data.
Any ideas? Thanks
Update: I fixed the previous problem, but a problem still persists. I'm getting an error on the final line of code
ERROR Error: Uncaught (in promise): TypeError: Cannot read property '0' of undefined TypeError: Cannot read property '0' of undefined
export class TunesComponent implements OnInit {
sources: Array<Object>;
constructor(http: Http) {
http.get('https://bedtimetunes.restlet.net/v1/tuneses/')
.map(response => response.json())
.subscribe(sources => this.sources = sources);
}
currentIndex = 0;
currentItem: Object = this.sources[ this.currentIndex ];
Sorry I am new to TypeScript.