mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
23 lines
569 B
TypeScript
23 lines
569 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;
|
|
}
|