Files
JavaScriptServices/templates/VueSpa/ClientApp/components/fetchdata/fetchdata.ts
Steve Sanderson 360688f78b Add Vue template
2017-03-13 09:25:23 -07:00

23 lines
551 B
TypeScript

import Vue from 'vue';
import { Component, Lifecycle } from 'av-ts';
interface WeatherForecast {
dateFormatted: string;
temperatureC: number;
temperatureF: number;
summary: string;
}
@Component
export default class FetchDataComponent extends Vue {
forecasts: WeatherForecast[] = [];
@Lifecycle mounted() {
fetch('/api/SampleData/WeatherForecasts')
.then(response => response.json() as Promise<WeatherForecast[]>)
.then(data => {
this.forecasts = data;
});
}
}