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
2 changed files with 12 additions and 5 deletions

View File

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

View File

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