diff --git a/templates/Angular2Spa/ClientApp/app/components/fetchdata/fetchdata.component.ts b/templates/Angular2Spa/ClientApp/app/components/fetchdata/fetchdata.component.ts index e213bae..e93d4fa 100644 --- a/templates/Angular2Spa/ClientApp/app/components/fetchdata/fetchdata.component.ts +++ b/templates/Angular2Spa/ClientApp/app/components/fetchdata/fetchdata.component.ts @@ -10,7 +10,7 @@ export class FetchDataComponent { constructor(http: Http) { http.get('/api/SampleData/WeatherForecasts').subscribe(result => { - this.forecasts = result.json(); + this.forecasts = result.json() as WeatherForecast[]; }); } } diff --git a/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts b/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts index f135010..66cb447 100644 --- a/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts +++ b/templates/AureliaSpa/ClientApp/app/components/fetchdata/fetchdata.ts @@ -11,9 +11,9 @@ export class Fetchdata { constructor(http: HttpClient) { http.fetch('/api/SampleData/WeatherForecasts') - .then(result => result.json()) + .then(result => result.json() as Promise) .then(data => { - this.forecasts = data as any; + this.forecasts = data; }); } } diff --git a/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts b/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts index a6618cd..9576d66 100644 --- a/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts +++ b/templates/KnockoutSpa/ClientApp/components/fetch-data/fetch-data.ts @@ -13,8 +13,8 @@ class FetchDataViewModel { constructor() { fetch('/api/SampleData/WeatherForecasts') - .then(response => response.json()) - .then((data: WeatherForecast[]) => { + .then(response => response.json() as Promise) + .then(data => { this.forecasts(data); }); } diff --git a/templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts b/templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts index d027d2a..9631ccd 100644 --- a/templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts +++ b/templates/ReactReduxSpa/ClientApp/store/WeatherForecasts.ts @@ -46,8 +46,8 @@ export const actionCreators = { // Only load data if it's something we don't already have (and are not already loading) if (startDateIndex !== getState().weatherForecasts.startDateIndex) { let fetchTask = fetch(`/api/SampleData/WeatherForecasts?startDateIndex=${ startDateIndex }`) - .then(response => response.json()) - .then((data: WeatherForecast[]) => { + .then(response => response.json() as Promise) + .then(data => { dispatch({ type: 'RECEIVE_WEATHER_FORECASTS', startDateIndex: startDateIndex, forecasts: data }); }); diff --git a/templates/ReactSpa/ClientApp/components/FetchData.tsx b/templates/ReactSpa/ClientApp/components/FetchData.tsx index 2ee2f1d..e76625b 100644 --- a/templates/ReactSpa/ClientApp/components/FetchData.tsx +++ b/templates/ReactSpa/ClientApp/components/FetchData.tsx @@ -12,8 +12,8 @@ export class FetchData extends React.Component { this.state = { forecasts: [], loading: true }; fetch('/api/SampleData/WeatherForecasts') - .then(response => response.json()) - .then((data: WeatherForecast[]) => { + .then(response => response.json() as Promise) + .then(data => { this.setState({ forecasts: data, loading: false }); }); }