Hi,
I'm suggesting a minor edit for the code in app.js in client directory as I tried the tutorial that you have set up.
Please let me know your thoughts. Thank you
class App extends Component to be class App extends React.Component instead for it to work.
import React from 'react';
import logo from './logo.svg';
import './App.css';
class App extends React.Component {
constructor(props) {
super(props);
this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/testAPI")
.then(res => res.text())
.then(res => this.setState({ apiResponse: res }))
.catch(err => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
Welcome to React
{this.state.apiResponse}
);
}
}
export default App;
Hi,
I'm suggesting a minor edit for the code in app.js in client directory as I tried the tutorial that you have set up.
Please let me know your thoughts. Thank you
class App extends Component to be class App extends React.Component instead for it to work.
import React from 'react';
import logo from './logo.svg';
import './App.css';
class App extends React.Component {
constructor(props) {
super(props);
this.state = { apiResponse: "" };
}
callAPI() {
fetch("http://localhost:9000/testAPI")
.then(res => res.text())
.then(res => this.setState({ apiResponse: res }))
.catch(err => err);
}
componentDidMount() {
this.callAPI();
}
render() {
return (
Welcome to React
{this.state.apiResponse}
);
}
}
export default App;