How to Consume Github Api with Search Feature

I am working on a simple app using github api to implement a search box which then print out the result of the search. I have been struggling to build the search box (GithubSearch.js) to detect the specific Github features and print it out. Someone should please continue from where I stopped and implement the said feature Thanks.

You should create a controlled input in the search form and lift fetching and state from GithubProfile to GithubSearch:
https://codesandbox.io/s/ecstatic-elion-rm6bq?file=/src/GithubSearch.jsx

1 Like

Hello, thanks a lot for your prompt response and easy to understood solution you use. Please, I will like to ask you a few questions.
Can you explain this line : if (!this.state.userInput.trim()) return;
Also when entrying a username and pressing the go button, it seems not to do anything.
If you don’t mind, please can you re-implemented it so that another user detail of Github would be displayed when I press the Go button. Thanks a lot.

.trim() removes whitespaces from the beginning and the end of the string.
That line prevents submitting if userInput is empty or consists of empty spaces.

Works for me (e.g. with “octocat”, “github”).

Alright then, may be I was wrong for saying that the Go button did not work.
But what about if I want to search for another User github detail apart from me, Can you also implement that.

So sorry, it is actually working well with other user github also. You did a fantastic work. I am going to mark it now as the solution. Thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.