Files
2016-08-19 01:40:35 +01:00

24 lines
600 B
TypeScript

import * as ko from 'knockout';
import 'isomorphic-fetch';
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') };