Fix unhandled promise reject from jenkins.

This commit is contained in:
kialam 2018-11-13 12:11:52 -05:00 committed by Jake McDermott
parent 03f6e52cf1
commit b0855ee33d
No known key found for this signature in database
GPG Key ID: 9A6F084352C3A0B7
2 changed files with 12 additions and 5 deletions

View File

@ -45,7 +45,6 @@ class APIClient {
}
get = (endpoint) => this.http.get(endpoint);
}
export default new APIClient();

View File

@ -15,17 +15,24 @@ class Organizations extends Component {
constructor (props) {
super(props);
this.state = { organizations: [] };
this.state = {
organizations: [],
error: false,
};
}
async componentDidMount () {
const { data } = await api.get(API_ORGANIZATIONS);
this.setState({ organizations: data.results });
try {
const { data } = await api.get(API_ORGANIZATIONS);
this.setState({ organizations: data.results });
} catch (err) {
this.setState({ error: err });
}
}
render () {
const { light, medium } = PageSectionVariants;
const { organizations } = this.state;
const { organizations, error } = this.state;
return (
<Fragment>
@ -39,6 +46,7 @@ class Organizations extends Component {
<OrganizationCard key={o.id} organization={o} />
</GalleryItem>
))}
{ error ? <div>error</div> : '' }
</Gallery>
</PageSection>
</Fragment>