I'm following the Angular tutorial at https://angular.io/tutorial/toh-pt6 which shows how to retrieve a Json response from an API call, and then match that to a promise.
The specific example is:
getHeroes(): Promise<Hero[]> {
return this.http.get(this.heroesUrl)
.toPromise()
.then(response => response.json().data as Hero[])
.catch(this.handleError);
}
I'm using the AWS API gateway, the use of which is detailed at http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-generate-sdk-javascript.html
Being new to both Typescript and promises, how do I modify the sample method to fit into the structure of the Angular tutorial?
apigClient.methodName(params, body, additionalParams)
.then(function(result){
// Add success callback code here.
}).catch( function(result){
// Add error callback code here.
});
In my example, result.data is an array of JSON objects.