Skip to content

Minor edit for app.js in client directory #2

Description

@prwhoeatsnonstop

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 (



logo

Welcome to React



{this.state.apiResponse}



);
}
}

export default App;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions