-
Notifications
You must be signed in to change notification settings - Fork 1
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
팔로우, 팔로우 취소 기능 구현 #31
Conversation
- 사용자명 8자, 실명 6자 이하 검사 기능을 추가했습니다.
- 비밀번호 변경 시 유효성을 검사하는 기능을 추가했습니다.
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.
팔로잉, 팔로워를 눌렀을 때 사용자 목록이 나타나는 디자인을 추가하는 건 어떨까요?
좋은 아이디어네요!!
API 요청 시 토큰을 사용하는 함수가 꽤 있는 것 같습니다. 이를 하나의 상수로 불러와서 사용하는 건 어떨까요? 너무 과할까요?
저도 휘식님 의견처럼 토큰을 사용하는 로직을 분리해서 사용하는 것에 동의합니다!
api.ts 파일에 토큰이 필요한 API 요청들을 위한 인스턴스와 토큰이 필요하지 않은 API 요청들을 위한 인스턴스로 나누어 생성하고, axios interceptors를 이용해서 헤더에 토큰을 설정하는 방법도 있을 것 같습니다😊
https://axios-http.com/kr/docs/interceptors
https://growing-jiwoo.tistory.com/85
import axios from 'axios'
// 토큰이 필요한 요청을 위한 인스턴스
const axiosInstanceWithToken = axios.create({
baseURL: `${import.meta.env.VITE_BASE_URL}:${import.meta.env.VITE_APP_PORT}`,
timeout: 5000,
headers: { 'Content-Type': 'application/json' }
})
axiosInstanceWithToken.interceptors.request.use(config => {
const token = localStorage.getItem('token')
const parsedToken = JSON.parse(token as string)
config.headers['Authorization'] = `Bearer ${parsedToken}`
return config
}, error => {
return Promise.reject(error)
})
// 토큰이 필요하지 않은 요청을 위한 인스턴스
const axiosInstance = axios.create({
baseURL: `${import.meta.env.VITE_BASE_URL}:${import.meta.env.VITE_APP_PORT}`,
timeout: 5000,
headers: { 'Content-Type': 'application/json' }
})
export { axiosInstanceWithToken, axiosInstance }
이 부분은 현재 구현하고 있는 기능들 merge 하고, 전체적인 리팩터링 할 때 시도해 보면 좋을 것 같아요!
src/pages/Profile/components/profile-edit-drawer/ProfileNameForm.tsx
Outdated
Show resolved
Hide resolved
좋습니다! 인스타/페이스북 등을 참고하면 좋을듯 하네요
저도 고민했던 문제 중 하나였는데요. 이건 윤경님이 얘기해주신 axios interceptor를 사용해서 따른 분리하는 방법이 좋을거 같습니다 |
관련 이슈
작업 내용
특이 사항
리뷰 요구사항 (선택)