mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 01:58:29 +00:00
25 lines
716 B
TypeScript
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;
|
|
}
|