-
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 pull request #26 from 14-team13/11-feature-axios-instance
11 feature axios instance
- Loading branch information
Showing
7 changed files
with
134 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import axios from "axios"; | ||
|
||
const request = axios.create({ | ||
baseURL: "http://localhost:8123" | ||
}) | ||
|
||
//요청 타임아웃 설정 | ||
request.defaults.timeout = 2500; | ||
request.defaults.withCredentials = true; | ||
// request.defaults.headers.common['Authorization'] = `Bearer ${accessToken}`; | ||
|
||
//요청 인터셉터 추가 | ||
request.interceptors.request.use( | ||
config => { //요청을 보내기 전에 수행할 로직 | ||
return config | ||
}, | ||
error => { | ||
//요청 에러가 발생했을 때 수행할 로직 | ||
console.log(error); //디버깅 | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
//응답 인터셉터 추가 | ||
request.interceptors.response.use( | ||
response => { | ||
//응답에 대한 로직 작성 | ||
//const res = response.data | ||
//return res | ||
return response | ||
}, | ||
|
||
error => { | ||
//응답 에러가 발생했을 때 수행할 로직 | ||
console.log(error); //디버깅 | ||
return Promise.reject(error); | ||
} | ||
); | ||
|
||
|
||
export default request; //axios 인스턴스를 내보낸다. |
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,30 @@ | ||
import request from "./core"; | ||
|
||
|
||
export const login = (email: string, password: string) => { | ||
return request( | ||
{ | ||
method: 'POST', | ||
url: '/login', | ||
data: { | ||
email: email, | ||
password: password | ||
} | ||
} | ||
) | ||
} | ||
|
||
export const loginsuccess = () => { | ||
return request({ | ||
// method: 'GET', | ||
url: '/login/success' | ||
}); | ||
} | ||
|
||
export const logout = () => { | ||
return request({ | ||
method: 'POST', | ||
url: '/logout' | ||
}); | ||
} | ||
|
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
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