Abort controller / Fetch data only if token valid #3

Open
opened 2022-11-04 23:30:46 +01:00 by karma · 0 comments
Owner

Create an abort controller to abort requests when the token is not valid anymore.

Concrete example:

When user is in / and the token is not valid anymore and they refresh the page, the useEffect() to fetch the customer info and table data is made, regardless of whether the token is valid or not. If the token is invalid the requests throws an error (since the token is not recognized).

Possible solution

  • Make the request to fetch the customer info only after checking if the token is valid (hard because this happens in the AuthComponent which is outside the Transactions component)
  • Create an Abort controller that aborts the request in the return of the useEffect (which is run as 'cleanup' when the component is unmounted).
Create an abort controller to abort requests when the token is not valid anymore. ## Concrete example: When user is in `/` and the token is not valid anymore and they refresh the page, the `useEffect()` to fetch the customer info and table data is made, regardless of whether the token is valid or not. If the token is invalid the requests throws an error (since the token is not recognized). ## Possible solution - Make the request to fetch the customer info only after checking if the token is valid (hard because this happens in the `AuthComponent` which is outside the `Transactions` component) - Create an `Abort controller` that aborts the request in the return of the `useEffect` (which is run as 'cleanup' when the component is unmounted).
karma added the
Priority 3
label 2022-11-04 23:30:46 +01:00
karma added this to the Project (Mario?) project 2022-11-04 23:30:46 +01:00
karma added this to the Milestone 10.11.2022 milestone 2022-11-04 23:47:47 +01:00
karma modified the milestone from Milestone 10.11.2022 to End of project 2022-11-04 23:48:43 +01:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: karma/zucchetti-sa5#3
No description provided.