Skip to content

Commit 297dfae

Browse files
committed
♻️ [refactor] : axios 인스턴스명 변경
1 parent 1a46b8e commit 297dfae

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/api/test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import axios from '../utils/axios'
1+
import axiosInstance from '../utils/axios'
22

33
export const getNotifications = async () => {
4-
const response = await axios.get('/api/notifications?page=0&size=5')
4+
const response = await axiosInstance.get('/api/notifications?page=0&size=5')
55
return response.data
66
}
77

88
export const postLogin = async (nickname: string, password: string) => {
9-
const response = await axios.post('/api/auths/login', { nickname, password })
9+
const response = await axiosInstance.post('/api/auths/login', { nickname, password })
1010
return response.data
1111
}
1212

1313
export const patchReadNotification = async (notificationId: number) => {
14-
const response = await axios.patch(`/api/notification/${notificationId}`)
14+
const response = await axiosInstance.patch(`/api/notification/${notificationId}`)
1515
return response.data
1616
}

src/utils/axios.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import axios, { type InternalAxiosRequestConfig } from 'axios'
22
import Cookies from 'js-cookie'
33
const baseURL = import.meta.env.VITE_API_BASE_URL
44

5-
const instance = axios.create({
5+
const axiosInstance = axios.create({
66
baseURL: baseURL,
77
withCredentials: true,
88
headers: {
@@ -11,7 +11,7 @@ const instance = axios.create({
1111
}
1212
})
1313

14-
instance.interceptors.request.use(
14+
axiosInstance.interceptors.request.use(
1515
(config: InternalAxiosRequestConfig) => {
1616
if (typeof window !== 'undefined') {
1717
const token = Cookies.get('accessToken')
@@ -24,7 +24,7 @@ instance.interceptors.request.use(
2424
error => Promise.reject(error)
2525
)
2626

27-
instance.interceptors.response.use(
27+
axiosInstance.interceptors.response.use(
2828
response => response,
2929
error => {
3030
if (axios.isCancel(error)) {
@@ -55,4 +55,4 @@ instance.interceptors.response.use(
5555
}
5656
)
5757

58-
export default instance
58+
export default axiosInstance

0 commit comments

Comments
 (0)