LasyaPriya LasyaPriya - 2 months ago 36
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.


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.