I just started looking at reactjs and trying to retrieve data from an API:
constructor(){
super();
this.state = {data: false}
this.nextProps ={};
You can try with below example code and let me know if you needed any further help in this.
var YourComponentName = React.createClass({
componentDidMount: function() {
var that = this;
// Your API would be calling here and get response and set state here as below example
// Just an example here with AJAX something you can do that.
$.ajax({
url: 'YOURURL',
dataType: 'json',
type: 'POST',
data: data,
success: function(response) {
that.setState({data: response})
}
});
},
render: function() {
return ();
}
});
Thanks!