"how to make a github api using react" Code Answer's
You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "how to make a github api using react" answered properly. Developers are finding an appropriate answer about how to make a github api using react related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like how to make a github api using react. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on how to make a github api using react.
how to make a github api using react
class GitHubSearch extends React.Component {
constructor(props){
super(props);
this.state = {
username: '',
userrepo: '',
};
}
getUser(username) {
return fetch(`https://api.github.com/users/${username}`)
.then(response => response.json())
.then(response => {
return response;
})
}
getUserRepo(userrepo) {
return fetch(`https://api.github.com/users/${username}/repos`)
.then(response => response.json())
.then(response => {
return response;
})
}
async handleSubmit(e) {
e.preventDefault();
let user = await this.getUser(this.refs.username.value);
this.setState({ avatar_url: user.avatar_url,
username: user.login,
followers: user.followers,
following: user.following,
url: user.url,
});
let repo = await this.getUserRepo(this.refs.userrepo.value);
this.setState({ name: repo.name,
description: repo.description,
git_url: repo.git_url,
stargazers_count: repo.stargazers_count,
forks_count: repo.forks_count,
open_issues_count: repo.open_issues_count,
size: repo.size,
})
}
render() {
let user;
if(this.state.username) {
user =
<div className="resultBadge">
<img src={this.state.avatar_url}/>
<p className="userInfo">
Username: <br/>
{this.state.username}
</p>
<p className="followerInfo">
{this.state.followers} Followers
</p>
<p className="followingInfo">
Following {this.state.following} users
</p>
</div>
}
let repo;
if(this.state.userrepo) {
repo =
<div className="repoResults">
<p>
{this.state.name}
</p>
</div>
}
return (
<div className="GitHubSearch">
<header className="Search-header">
<h1>Github User Search </h1>
</header>
<form onSubmit={e => this.handleSubmit(e)}>
<input ref='username' type='text' placeholder='username' />
</form>
<p className="Search-intro">
{user}
</p>
<p>
{repo}
</p>
</div>
);
}
}
ReactDOM.render(<GitHubSearch/>, document.getElementById('container'));
Source: stackoverflow.com
All those coders who are working on the Javascript based application and are stuck on how to make a github api using react can get a collection of related answers to their query. Programmers need to enter their query on how to make a github api using react related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about how to make a github api using react for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of how to make a github api using react while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "how to make a github api using react". Visit this developer's friendly online web community, CodeProZone, and get your queries like how to make a github api using react resolved professionally and stay updated to the latest Javascript updates.