LasyaPriya LasyaPriya - 1 year ago 113
React JSX Question

How do I access data returned from an axios get to display on a web page using react js?

I have ajax functions in an api to which I'm making an axios get request from my react js component. How can I access the returned data to display it on the web page.

Answer Source

Depends of what you trying to do but this is a example.

componentDidMount() {
    .then(res => this.setState({ posts: }))
    .catch(err => console.log(err))

A good way too should be if you using react-router to make the ajax call with the onEnter api from the router.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download