Abort controller / Fetch data only if token valid #3
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, theuseEffect()
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
AuthComponent
which is outside theTransactions
component)Abort controller
that aborts the request in the return of theuseEffect
(which is run as 'cleanup' when the component is unmounted).