Skip to content

Commit

Permalink
feat: axios request interceptors 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaerim committed Feb 26, 2023
1 parent f260749 commit 6aeac9f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/apis/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,23 @@ axiosClient.interceptors.response.use(
)
);

// 1. 요청 인터셉터
axiosClient.interceptors.request.use(
function (config) {
if (config?.headers == null) {
throw new Error(`config.header is undefined`);
}
config.headers['Content-Type'] = 'application/json; charset=utf-8';
config.headers['Authorization'] = authToken.access;

return config;
},
function (error) {
return Promise.reject(error);
}
);

// 2. 응답 인터셉터
axiosClient.interceptors.response.use(
response => response.data,
async function (error: EffError) {
Expand Down

0 comments on commit 6aeac9f

Please sign in to comment.