mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Make 'fetchdata' components in templates compatible with latest TypeScript compiler
This commit is contained in:
@@ -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[];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<WeatherForecast[]>)
|
||||
.then(data => {
|
||||
this.forecasts = data as any;
|
||||
this.forecasts = data;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ class FetchDataViewModel {
|
||||
|
||||
constructor() {
|
||||
fetch('/api/SampleData/WeatherForecasts')
|
||||
.then(response => response.json())
|
||||
.then((data: WeatherForecast[]) => {
|
||||
.then(response => response.json() as Promise<WeatherForecast[]>)
|
||||
.then(data => {
|
||||
this.forecasts(data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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<WeatherForecast[]>)
|
||||
.then(data => {
|
||||
dispatch({ type: 'RECEIVE_WEATHER_FORECASTS', startDateIndex: startDateIndex, forecasts: data });
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ export class FetchData extends React.Component<any, FetchDataExampleState> {
|
||||
this.state = { forecasts: [], loading: true };
|
||||
|
||||
fetch('/api/SampleData/WeatherForecasts')
|
||||
.then(response => response.json())
|
||||
.then((data: WeatherForecast[]) => {
|
||||
.then(response => response.json() as Promise<WeatherForecast[]>)
|
||||
.then(data => {
|
||||
this.setState({ forecasts: data, loading: false });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user