Skip to content

Commit

Permalink
set altinnError dersom vi får hard feil
Browse files Browse the repository at this point in the history
dette vil også skje når retries er exhausted
  • Loading branch information
kenglxn committed Oct 5, 2023
1 parent a408d02 commit 803c009
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/App/useUserInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const fallbackData = {
};
type UserInfo = z.infer<typeof UserInfoRespons>;
export const useUserInfo = (): UserInfo => {
const { data } = useSWR('/min-side-arbeidsgiver/api/userInfo/v1', fetcher, {
const { data, error } = useSWR('/min-side-arbeidsgiver/api/userInfo/v1', fetcher, {
onErrorRetry: (error, key, config, revalidate, { retryCount }) => {
if ((error.status === 502 || error.status === 503) && retryCount <= 5) {
setTimeout(() => revalidate({ retryCount }), 500);
Expand All @@ -44,7 +44,7 @@ export const useUserInfo = (): UserInfo => {
fallbackData,
});

return data ?? fallbackData;
return data ?? { ...fallbackData, altinnError: error !== undefined };
};

const fetcher = async (url: string) => {
Expand Down

0 comments on commit 803c009

Please sign in to comment.