0
I am consuming the Github API and I am browsing the repositories of a particular user, but when trying to access the properties it is returning undefined
.
As you can see in the picture, mine result
is returning all objects from the repositories, but while trying to traverse them using the rep
which is being passed as parameter it returns only the first repository, but the idea would be to return all the repositories.
My function that traverses the repositories using the map()
:
getRepos = type => {
return e => {
axios
.get(`https://api.github.com/users/Giovanni001/${type}`)
.then(result => {
console.log("RESULT", result);
this.setState({
[type]: result.data.map(rep => {
console.log("REP", rep);
return {
name: rep.data.name,
link: rep.data.html_url
};
})
});
})
.catch(err => {
console.log("ERRO: ", err);
return <h1>Ops, deu algo errado !</h1>;
});
};
};
Hello, I had made a request in another function and I was taking the data using the date, I was so fixated on that q I did not realize that the date was already being passed in the loop, Thanks for the help !
– Pedro
This happens a lot during man development :)
– LeAndrade