Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm writing a functional ReactJS app that search for GitHub users and displays them in a list. The user list should display the number of user repositories. But the problem is that I don't know how to get a list of repositories for each user, but I only know how to search for the repositories of one specific user.

On the main page, I search for users whose names match the input value and get a list of matches. If I go to the page of this user, then in it I can already get a list and the number of repositories of this user, but for this I have to send a separate request to the server for the user.

Is there any solution that will allow me to display the number of repositories for each user on the main page?

CodeSanbox Link

Inside Sanbox my code is unstable, but i hope, the main point must be clear

Finally it should looks like this, but instead ## symbols should be count of repos each users

Finnaly it should looks like this

question from:https://stackoverflow.com/questions/66066463/how-to-get-data-from-github-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
100 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can count the repositories of a particular getting the data from here: https://api.github.com/users/**username**/repos

And count the number of items in the response using :

Object.keys(resultData).length;

Here resultData is the response of the GET from the API above


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...