You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given I have multiple swr hook based components and to do something meaningful with the API at first the access to the API must be authenticated (via user/password, refresh token) and then the actual request can happen.
Since several components can initate a request to the API there must be some sync mechanism, that only the first swr fetcher does the authentication and all other fetchers must wait for the result of the authentication to continue (successfull authenticated) or abort (failure to authenticate) their request.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Given I have multiple swr hook based components and to do something meaningful with the API at first the access to the API must be authenticated (via user/password, refresh token) and then the actual request can happen.
Since several components can initate a request to the API there must be some sync mechanism, that only the first swr fetcher does the authentication and all other fetchers must wait for the result of the authentication to continue (successfull authenticated) or abort (failure to authenticate) their request.
So I came up with this pattern:
Beta Was this translation helpful? Give feedback.
All reactions