Files
JavaScriptServices/templates/VueSpa/ClientApp/components/fetchdata/fetchdata.ts

23 lines
545 B
TypeScript

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