mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-23 10:08:57 +00:00
23 lines
577 B
TypeScript
23 lines
577 B
TypeScript
import * as ko from 'knockout';
|
|
|
|
interface WeatherForecast {
|
|
dateFormatted: string;
|
|
temperatureC: number;
|
|
temperatureF: number;
|
|
summary: string;
|
|
}
|
|
|
|
class FetchDataViewModel {
|
|
public forecasts = ko.observableArray<WeatherForecast>();
|
|
|
|
constructor() {
|
|
fetch('/api/SampleData/WeatherForecasts')
|
|
.then(response => response.json())
|
|
.then((data: WeatherForecast[]) => {
|
|
this.forecasts(data);
|
|
});
|
|
}
|
|
}
|
|
|
|
export default { viewModel: FetchDataViewModel, template: require('./fetch-data.html') };
|