Skip to content
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

api 공통 로직 분리 및 accessToken 런타임 저장 #171

Open
ashleysyheo opened this issue Jun 28, 2023 · 0 comments
Open

api 공통 로직 분리 및 accessToken 런타임 저장 #171

ashleysyheo opened this issue Jun 28, 2023 · 0 comments
Assignees

Comments

@ashleysyheo
Copy link
Contributor

as is

  • accessToken이 필요한 경우 매번 getItem을 한다
  • accessToken을 가지고 온 다음에 accessTokennull이면 오류 처리를 각 api 함수에서 한다
    if (!accessToken) {
      window.sessionStorage.removeItem(ACCESS_TOKEN);
      window.alert("다시 로그인 해주세요");
      window.location.reload();
      return;
    }
  • Authorization 정보가 필요한 경우 매번 Authorization: Bearer ${accessToken}을 추가하고 있다

to be

  • accessToken을 런타임에서 들고 있는다
  • api 함수에서 공통된 로직을 axios interceptor를 이용하거나 유틸 함수로 분리한다
  • Authorization: Bearer ${accessToken}을 api 요청 보내기 전에 미리 처리한다
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant