Files
JavaScriptServices/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts
2016-10-28 11:16:21 +01:00

25 lines
716 B
TypeScript

/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/whatwg-fetch.d.ts" />
/// <reference path="../../../../node_modules/aurelia-fetch-client/doc/url.d.ts" />
import { HttpClient } from 'aurelia-fetch-client';
import { inject } from 'aurelia-framework';
@inject(HttpClient)
export class Fetchdata {
public forecasts: WeatherForecast[];
constructor(http: HttpClient) {
http.fetch('/api/SampleData/WeatherForecasts')
.then(result => result.json())
.then(data => {
this.forecasts = data;
});
}
}
interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}