How to set state of response from axios in react
You have a syntax error here. You should try this instead var self = this; axios.get(‘/url’) .then(function (response) { console.log(response); self.setState({events: response.data}) }) .catch(function (error) { console.log(error); }); //the rest of the code var a=”i might be executed before the server responds” There are a few things to note here: axios.get is an asynchronous function … Read more