use optional chaining

This commit is contained in:
Keith Grant 2020-01-31 12:28:44 -08:00
parent b26de8b922
commit b8226109a7
2 changed files with 2 additions and 2 deletions

View File

@ -27,7 +27,7 @@ function HostAdd({ i18n }) {
const { data: response } = await HostsAPI.create(values);
history.push(`${url}/${response.id}/details`);
} catch (error) {
if (error.response && error.response.data) {
if (error.response?.data) {
throw error.response.data;
}
setFormError(error);

View File

@ -35,7 +35,7 @@ function HostEdit({ host, i18n }) {
await HostsAPI.update(host.id, values);
history.push(detailsUrl);
} catch (error) {
if (error.response && error.response.data) {
if (error.response?.data) {
throw error.response.data;
}
setFormError(error);