Skip to content

Commit

Permalink
Moved logging outside of the fetch function
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed Oct 20, 2023
1 parent a0d9725 commit f0a46f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions samples/endpoints/shell/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ async function fetchProtectedData(
setSubscription: SetSubscription,
logger: Logger
) {
logger.debug(`[shell] Fetching session data as "${window.location}" is a protected route.`);

const sessionPromise = axios.get("/api/session")
.then(({ data }) => {
const session: Session = {
Expand Down Expand Up @@ -85,6 +83,8 @@ export function RootRoute({ setSession, setSubscription }: RootRouteProps) {
if (isActiveRouteProtected && !isAuthenticated) {
setIsReady(false);

logger.debug(`[shell] Fetching protected data as "${location}" is a protected route.`);

fetchProtectedData(setSession, setSubscription, logger).finally(() => {
setIsReady(true);
});
Expand Down Expand Up @@ -144,6 +144,8 @@ export function AppRouter({ waitForMsw, sessionManager, telemetryService }: AppR

if (areModulesReady && isMswStarted) {
if (isActiveRouteProtected) {
logger.debug(`[shell] Fetching protected data as "${window.location}" is a protected route.`);

fetchProtectedData(setSession, setSubscription, logger).finally(() => {
setIsReady(true);
});
Expand Down

0 comments on commit f0a46f0

Please sign in to comment.