-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/modern-agile-team/8term-…
…main-front into feature/#46/quiz
- Loading branch information
Showing
7 changed files
with
49 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ yarn-debug.log* | |
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
.env | ||
node_modules | ||
dist | ||
dist-ssr | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import axios from 'axios'; | ||
const api = axios.create({ | ||
baseURL: import.meta.env.VITE_BASE_URL, | ||
timeout: 5000, | ||
}); | ||
export default api; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import axiosConfig from './instance'; | ||
axiosConfig.interceptors.request.use(config => { | ||
//요청 성공 직전 호출 | ||
//헤더에 인가 토큰 부착 | ||
//로컬스토리지에 저장한다고 가정한다면 | ||
console.log('asdasd'); | ||
const accessToken: string | null = localStorage.getItem('Token'); | ||
if (accessToken !== null) { | ||
config.headers.Authorization = `Bearer ${accessToken}`; | ||
} | ||
|
||
return config; | ||
}); | ||
axiosConfig.interceptors.response.use( | ||
//http status가 200번대인 경우 호출 | ||
response => response, | ||
error => { | ||
//http status가 에러 코드인경우 실행 | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const HTTP_STATUS = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import Quiz from '../admin/types/Quiz'; | ||
import api from './axios/instance'; | ||
|
||
const QUIZ = { | ||
getQuizzes: (sectionId: number, part: Quiz['part']) => { | ||
return useQuery({ | ||
queryKey: ['quizzes', { sectionId, part }], | ||
queryFn: () => api.get(`/quizzes?sectionId=${sectionId}&part=${part}`), | ||
gcTime: 5 * 60 * 1000, // 5분 | ||
staleTime: 1 * 60 * 1000, // 1분 | ||
}); | ||
}, | ||
}; | ||
export default QUIZ; |