diff --git a/src/resource-group-affinity-group.jsx b/src/resource-group-affinity-group.jsx index 681e606..29404d7 100644 --- a/src/resource-group-affinity-group.jsx +++ b/src/resource-group-affinity-group.jsx @@ -9,7 +9,7 @@ export default function ResourceGroupAffinityGroup({ baseUri, infoGroupId }) { null, { corsProxy: true } ); - if (!data || !data.length) return; + if (!data || data.error || !data.length) return; const slackUri = stripTags(data[0].slack_link); return (
diff --git a/src/resource-group-description.jsx b/src/resource-group-description.jsx index 68af7dd..ce1b405 100644 --- a/src/resource-group-description.jsx +++ b/src/resource-group-description.jsx @@ -8,7 +8,7 @@ export default function ResourceGroupDescription({ baseUri, infoGroupId }) { null, { corsProxy: true } ); - if (!data || !data.length) return; + if (!data || data.error || !data.length) return; const name = data[0].title; const imageUri = `https://support.access-ci.org/${data[0].field_image}`; const description = htmlToJsx(data[0].description); diff --git a/src/utils.jsx b/src/utils.jsx index 6775f04..c80cf66 100644 --- a/src/utils.jsx +++ b/src/utils.jsx @@ -38,7 +38,12 @@ export const useJSON = ( if (res.status < 200 || res.status > 299) { setValue({ error: { status: res.status } }); } else { - const data = await res.json(); + let data; + try { + data = await res.json(); + } catch (error) { + setValue({ error: { message: error } }); + } setValue(data); } })();