I am currently working on a small project to build a web application to visualize some local data produced by some Python scripts I have already finished, and the front-end data visualization is written in react. I am kinda confused how could I fetch the data to represent on my web app. I saw some suggestion of using fetch() instead of jQuery. But everything I have done yet is just locally hosted, so how could I make the request to Python scripts in React and how should I retrieve params from the fetch() request in Python? Thank you!
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import RadarChart from './components/RadarChart';
import LineChart from './components/LineChart';
class App extends Component {
constructor() {
super();
this.state = {
bioData: {},
appData: {}
}
}
componentWillMount() {
this.getChartData();
}
static lastSyncTime = "2017-06-28";
getChartData() {
// TODO: AJAX calls/fetch() request here to retrieve data as well as pass a param: lastTimeSync to Python scripts
this.setState({
});
}
render() {
return (
<div className="App">
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Daily Report</h2>
</div>
<LineChart chartData={this.state.bioData} />
<br/>
<button onClick = {this.handleRefreshLine}>Refresh</button>
<br/>
<RadarChart chartData={this.state.appData} />
</div>
);
}
}
export default App;