diff --git a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/ClientApp/components/fetchdata/fetchdata.ts b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/ClientApp/components/fetchdata/fetchdata.ts index c6108f9303..ce64f81932 100644 --- a/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/ClientApp/components/fetchdata/fetchdata.ts +++ b/src/Microsoft.AspNetCore.SpaTemplates/content/Vue-CSharp/ClientApp/components/fetchdata/fetchdata.ts @@ -12,11 +12,14 @@ interface WeatherForecast { export default class FetchDataComponent extends Vue { forecasts: WeatherForecast[] = []; - mounted() { - fetch('api/SampleData/WeatherForecasts') - .then(response => response.json() as Promise) - .then(data => { - this.forecasts = data; - }); + async mounted() { + try { + let response = await fetch('api/SampleData/WeatherForecasts'); + let data = await response.json(); + this.forecasts = data; + } + catch (err) { + console.log(err); + } } }