Skip to content

Commit

Permalink
[do not merge] Introduce extra requests on the initial path of the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Nov 6, 2024
1 parent ec45e5a commit 4c9c24e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,22 @@ function Routing({ Component, pageProps, accessToken }: AppProps & { accessToken
const { getFeatureFlag } = useLaunchDarkly();

useEffect(() => {
bootstrapApp(accessToken).then(setStore);
// @ts-ignore
async function fetchAndLog(url: string): any {
const response = await fetch('https://swapi.dev/api/people');
const json = await response.json();
console.log(json);
return json;
}
bootstrapApp(accessToken)
.then(async store => {
try {
const response = await fetchAndLog('https://swapi.dev/api/people');
await fetchAndLog(response.next)
} catch {}
return store;
})
.then(setStore);
}, [accessToken]);

if (!store) {
Expand Down Expand Up @@ -156,4 +171,4 @@ App.getInitialProps = (appContext: AppContext) => {
return { ...props, ...authProps };
};

export default App;
export default App;

0 comments on commit 4c9c24e

Please sign in to comment.