Created
October 11, 2018 08:17
-
-
Save AlexKott/e8e6f5b205ab1f6e73c2827ca6db46b5 to your computer and use it in GitHub Desktop.
Fetching data in componentDidMount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserProfile extends React.Component { | |
// ... | |
async componentDidMount() { | |
const { data } = await httpAdapter.get(`${API_URL}/users/${this.props.userId}`); | |
this.setState({ user: data.user }); | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment