Files
JavaScriptServices/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts

23 lines
568 B
TypeScript

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() as Promise<WeatherForecast[]>)
.then(data => {
this.forecasts = data;
});
}
}
interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}