1
I’m creating a Reactjs application that hits the Github API and brings the user
and the repositories.
But I wanted to bring the commits from every repository and I’m not getting.
My code is this:
async handleSubmit(e) {
e.preventDefault();
let user = await this.getUser(this.refs.username.value);
let repo = await this.getUserRepo(this.refs.username.value);
for(let i = 0; i < repo.length;i++){
let commitao = []
var comitasso = []
commitao = await this.getReposCommit(this.refs.username.value, repo[i].name);
comitasso.push(commitao)
console.log(commitao)
}
console.log(comitasso)
this.setState({
avatar_url: user.avatar_url,
username: user.login,
id: user.id,
url: user.html_url,
message: user.message,
reponame: repo,
});
The problem is that when I do console.log(comitasso)
, he brings me only the last record.
Ever tried to make
comitasso.push(commitao[0])
? Or give console.log(commit) before giving thepush
?– Edward Ramos
Generally, the
this.getReposCommit()
should bring an object or an object array, so I asked about giving the console.– Edward Ramos
can put an example of the data returning in "commitao"?
– Ricardo Pontual
@Leandro, Do not change the question to thank/indicate that the problem has been solved, start a new question in the same post. The best way to thank and accepting the answer who helped you. For these reasons I reverse the edit. =D -- Take a look at our [Tour] to better understand the functioning of the community.
– Icaro Martins