Skip to content

Commit bd34cac

Browse files
author
Kawsar Ahmed
authored
Merge pull request #7 from GianOrtiz/warn-username-not-found
Added warn if username not found
2 parents 2445ce5 + 9821da6 commit bd34cac

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/Components/SearchBar.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default class SearchBar extends Component {
1515
userData: [],
1616
searchButton: 'Search',
1717
}
18-
18+
1919
}
2020
handleChange = (e) =>{
2121
this.setState({
@@ -53,6 +53,17 @@ export default class SearchBar extends Component {
5353
searchButton: 'Search'
5454
});
5555
console.log(this.state)
56+
}).catch(error=>{
57+
if(error.response){
58+
if(error.response.status === 404) {
59+
toast.warn('Username not found');
60+
this.setState({
61+
reposData: [],
62+
userData: [],
63+
searchButton: 'Search'
64+
});
65+
}
66+
}
5667
});
5768
}
5869

@@ -67,7 +78,7 @@ export default class SearchBar extends Component {
6778
<Avatar
6879
data={this.state.userData}
6980
/>
70-
<PanelBoard
81+
<PanelBoard
7182
data={this.state.reposData}
7283
/>
7384
<ToastContainer
@@ -76,16 +87,16 @@ export default class SearchBar extends Component {
7687
autoClose={3000}
7788
/>
7889
</div>
79-
90+
8091
);
8192
}
8293
}
8394

8495
class PanelBoard extends Component {
85-
96+
8697
render(){
8798
const repos = this.props.data.map((repo) => (
88-
99+
89100
<ResultPanel
90101
id={repo.id}
91102
key={repo.id}

0 commit comments

Comments
 (0)