Skip to content
Snippets Groups Projects
Commit cd3d164e authored by Mikkel Aas's avatar Mikkel Aas
Browse files

getMainIdentifier now handles response codes that are not ok

parent 04214f5f
No related branches found
No related tags found
1 merge request!87Update fetch calls
......@@ -15,10 +15,14 @@ export default function UserMainIdentifierView(): JSX.Element {
const getMainIdentifier = async () => {
try {
const result = await fetch(USER_GET_MAIN_IDENTIFIER);
const jsonResult = await result.json();
setMainIdentifier(jsonResult.mainIdentifier);
const response = await fetch(USER_GET_MAIN_IDENTIFIER);
if (!response.ok) {
setMainIdentifier(undefined);
return;
} else {
const json = await response.json();
setMainIdentifier(json.mainIdentifier);
}
} catch (error) {
console.error(error);
} finally {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment