-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix - Redirection to Login if Response Status is 302 #517
Conversation
Dicas para revisão de códigoCommits
SonarCloud Quality Gate
Build Github actions COM SUCESSOReactJS
ReduxAs instruções a seguir foram retiradas do Redux Style Guide.
|
@fberanizo Teria como subir o código desta branch em um ambiente com login para testarmos se o que fiz funciona? Acredito que funciona sim porque simulei em um com login, mas nada como testar de verdade. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minha percepção é que adicionando o interceptor em cada service fica mais fácil de entender, porém mais verboso (com código duplicado).
Se tivesse uma função "fábrica" pra substituir o axios.create, e que já adicionasse o interceptor, acho ficaria mais enxuto o código. Essa sugestão tem uma desvantagem de tornar o desenvolvimento de futuros services anti-natural, principalmente pra novos devs (não se usaria o axios diretamente).
Bem...tem prós e contras.
@schafferjrdev como você prefere?
Agora está funcionando e consegui criar a factory com as tipagens do axios. @fberanizo Já pode testar no |
Acho que não tem muito problema do jeito que ficou. O que você acha @LuanEdCosta ? |
SonarCloud Quality Gate failed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
AuthExpired interceptor
inside theservices
folderAuthExpired interceptor
in all API instancesservices
folder return the axios instanceAuthExpired interceptor
AuthExpired interceptor
attached. This factory adds a identifier to the instance, so it's possible to check later if a instance was created with the factory.P.S. Attach the interceptor to the axios directly is a bad practice because in the future we may want to create an instance axios that does not redirect to the login if the response status be 302.