import React, { Component } from 'react'; export default class App extends Component { constructor(props) { super(props); this.state = { forecasts: [], loading: true }; } componentDidMount() { this.populateWeatherData(); } static renderForecastsTable(forecasts) { return ( {forecasts.map(forecast => )}
Date Temp. (C) Temp. (F) Summary
{forecast.date} {forecast.temperatureC} {forecast.temperatureF} {forecast.summary}
); } render() { let contents = this.state.loading ?

Loading... Please refresh once the ASP.NET backend has started. See https://aka.ms/jspsintegrationreact for more details.

: App.renderForecastsTable(this.state.forecasts); return (

Weather forecast

This component demonstrates fetching data from the server.

{contents}
); } async populateWeatherData() { const url = '/api/seasons'; if (process.env.NODE_ENV == 'production') { url = 'https://criminalminds-server.azurewebsites.net' + url; } const response = await fetch(url); const data = await response.json(); this.setState({ forecasts: data, loading: false }); } }