수정 전 코드
import axios from "axios";
export default function axiosGetData(url, data) {
return axios(url, {
method: "GET",
data: data,
})
.then((res) => res.data)
.catch((error) => console.log(error));
}
export default function axiosSetData(url, data) {
return axios(url, {
method: "POST",
headers: {
"content-type": "application/json",
},
data: data,
})
.then((res) => res.data)
.catch((error) => console.log(error));
}
기존에 작성하던 방식 그대로 export default function Name
으로 작성하다보니 Only one default export allowed per module
한 개의 default만 esport할 수 있다는 메세지가 나왔고, 아래와 같이 수정하였다.
수정한 코드
import axios from "axios";
function axiosGetData(url, data) {
return axios(url, {
method: "GET",
data: data,
})
.then((res) => res.data)
.catch((error) => console.log(error));
}
function axiosSetData(url, data) {
return axios(url, {
method: "POST",
headers: {
"content-type": "application/json",
},
data: data,
})
.then((res) => res.data)
.catch((error) => console.log(error));
}
export {axiosGetData, axiosSetData}
'front > react' 카테고리의 다른 글
[login API] Access Token & Refresh Token (0) | 2022.07.14 |
---|---|
NavArea.jsx:13 Uncaught TypeError: axiosData is not a function (0) | 2022.07.14 |
[login responsive css] 로그인 반응형 페이지 style & unsplash 랜덤이미지 사용 (0) | 2022.07.13 |
하위 컴포넌트가 상위 컴포넌트에게 useState 값 전달하는 방법 - props & function (0) | 2022.07.12 |
axios로 가져온 데이터를 이용하여 게시판 페이지 버튼과 게시판 코드 작성 - filter(), map(), table etc (1) | 2022.07.12 |