Skip to content

Commit

Permalink
Fix: Resolve uncaught errors when not logged in (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacoKoster committed Jul 18, 2023
1 parent df9ceb2 commit a06996b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/server-admin-ui/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,20 @@ export function restart() {
}
}

// Build actions that perform a basic authFetch to the backend. Pull #514.
export const buildFetchAction = (endpoint, type, prefix) => (dispatch) =>
authFetch(
`${isUndefined(prefix) ? window.serverRoutesPrefix : prefix}${endpoint}`
)
.then((response) => response.json())
.then((data) =>
export const buildFetchAction =
(endpoint, type, prefix) => async (dispatch) => {
const response = await authFetch(
`${isUndefined(prefix) ? window.serverRoutesPrefix : prefix}${endpoint}`
)

if (response.status === 200) {
const data = await response.json()
dispatch({
type,
data,
})
)
}
}

export const fetchLoginStatus = buildFetchAction(
'/loginStatus',
Expand Down

0 comments on commit a06996b

Please sign in to comment.