mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
27 lines
846 B
TypeScript
27 lines
846 B
TypeScript
// The following line is a workaround for aurelia-fetch-client requiring the type UrlSearchParams
|
|
// to exist in global scope, but that type not being declared in any public @types/* package.
|
|
/// <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() as Promise<WeatherForecast[]>)
|
|
.then(data => {
|
|
this.forecasts = data;
|
|
});
|
|
}
|
|
}
|
|
|
|
interface WeatherForecast {
|
|
dateFormatted: string;
|
|
temperatureC: number;
|
|
temperatureF: number;
|
|
summary: string;
|
|
}
|