Skip to content

Instantly share code, notes, and snippets.

@Arafat245
Last active April 3, 2016 00:15
Show Gist options
  • Save Arafat245/8a3e9234b99010498a291c78ae772143 to your computer and use it in GitHub Desktop.
Save Arafat245/8a3e9234b99010498a291c78ae772143 to your computer and use it in GitHub Desktop.
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
class App extends Component{
constructor(props) {
super(props);
this.state = {
username: 'Arafat245',
userData: [],
userRepos: [],
perPage: 5
}
}
//Get user data from github
getUserData() {
$.ajax({
url: 'https://api.github.com/users/'+this.state.username+'?client_id='+this.props.clientId+'&client_secret='+this.props.clientSecret,
dataType: 'json',
cache: false,
success: function(data){
console.log(data);
}.bind(this),
error: function(xhr, status, err){
alert(err);
}.bind(this)
});
}
componentDidMount() {
this.getUserData();
}
render(){
return(
<div>
{this.state.username}
</div>
)
}
}
App.propTypes = {
clientId: React.PropTypes.string,
clientSecret: React.PropTypes.string
};
App.defaultProps = {
clientId: 'ca055e97a5943e690082',
clientSecret: '69efeffa48741455f4553f7891b7347bee56283d'
};
export default App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment