Simple objects are necessary for fixing actions. utilise async actions with custom middleware.
-const logoutOnJWTExpiration: Middleware = () => (
+const logoutOnJWTExpiration: Middleware = (api) => (
next: ThunkDispatch<RootState, typeof api, AllActionsType>
) => action => {
const errorId = action.error?.id || action.payload?.id;
if (errorId === ErrorIDs.WRONG_AUTH_TOKEN) {
- next(logout());
+ api.dispatch(logout());
}
return next(action);
};
A form of computer code known as middleware gives software applications functions above and beyond what the operating system can offer. It's referred to as "software glue." Software developers can concentrate on the particular goal of their software by developing communication and input/output more easily due to middleware. Although the word has been in use since 1968, it only really became well-known in the 1980s as a way to link modern applications to more dated legacy systems. The phrase is most frequently used to refer to software that facilitates data storage and interaction in remote applications.
Learn more about middleware here:
https://brainly.com/question/13440971
#SPJ4