[TIL] 프레임워크 api 한 곳에서 정의(axios)

Captainjack·2022년 1월 3일
0

TIL

목록 보기
118/258

한 곳에 api를 정의 해 놓으니 좋은 것 같다


//axios.create = 공통 설정을 미리 정의한다.

const instance = axios.create({
  baseURL: process.env.VUE_APP_API_URL,
});

function registerUser(userData) {
  return instance.post('signup', userData);
}

function loginUser(userData) {
  return instance.post('login', userData);
}

export { registerUser, loginUser };

//파일경로 api/index.js

다음 프로젝트 진행하면서 퍼져있는 api를 한 곳에 정의 해야겠다.

profile
til' CTF WIN

0개의 댓글