Instantly share code, notes, and snippets.

@wKoza /promise.ts
Last active Jan 14, 2017

Embed
What would you like to do?
Promise<Article[]> articles = this.http.get('api.learn-angular.fr/articles')
.toPromise()
.then((res: Response) => res.json() as Article[])
.catch(this.handleError);
...
private handleError(error: any): Promise<any> {
console.error('Une erreur est survenue : ', error);
return Promise.reject(error.message || error);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment