728x90
// Add a request interceptor
axios.interceptors.request.use(function (config) {
// Do something before request is sent
return config;
}, function (error) {
// Do something with request error
return Promise.reject(error);
});
// Add a response interceptor
axios.interceptors.response.use(function (response) {
// Any status code that lie within the range of 2xx cause this function to trigger
// Do something with response data
return response;
}, function (error) {
// Any status codes that falls outside the range of 2xx cause this function to trigger
// Do something with response error
return Promise.reject(error);
});
https://github.com/axios/axios#interceptors
GitHub - axios/axios: Promise based HTTP client for the browser and node.js
Promise based HTTP client for the browser and node.js - GitHub - axios/axios: Promise based HTTP client for the browser and node.js
github.com
728x90
'Vue' 카테고리의 다른 글
Vue - VueRouter Navigation Guards (0) | 2022.03.25 |
---|---|
Vue - Vuex 헬퍼 함수 (0) | 2022.03.25 |
Vue - axios (Http 통신) (0) | 2022.03.25 |
Vue - Vuex (0) | 2022.03.25 |
Vue에서 fontawesome 설치 및 적용 (0) | 2022.02.16 |
댓글