diff --git a/src/apis/cards.js b/src/apis/cards.js index bf0b6d4..1afcdbd 100644 --- a/src/apis/cards.js +++ b/src/apis/cards.js @@ -1,29 +1,29 @@ import { authAxios } from '../axios'; // 전체 명함 조회 -export const getCards = async ({ member_id }) => { - const response = await authAxios.get(`/cards/${member_id}`); - // console.log(response.data.result); - return response; +export const getCardList = async (member_id) => { + const { data } = await authAxios.get(`/cards/${member_id}`); + + return data; }; // 명함 생성 -export const postCards = async ({ member_id, data }) => { - const response = await authAxios.post(`/cards/${member_id}`, data); - // console.log(response); - return response; +export const postCard = async (member_id, body) => { + const { data } = await authAxios.post(`/cards/${member_id}`, body); + + return data; }; // 명함 삭제 -export const deleteCards = async ({ card_id }) => { - const response = await authAxios.delete(`/cards/${card_id}`); - // console.log(response); - return response; +export const deleteCard = async (card_id) => { + const { data } = await authAxios.delete(`/cards/${card_id}`); + + return data; }; // 명함 수정 -export const putCards = async ({ card_id, data }) => { - const response = await authAxios.put(`/cards/${card_id}`, data); - // console.log(response); - return response; +export const putCard = async (card_id, body) => { + const { data } = await authAxios.put(`/cards/${card_id}`, body); + + return data; }; diff --git a/src/apis/index.js b/src/apis/index.js index 400c528..7851f99 100644 --- a/src/apis/index.js +++ b/src/apis/index.js @@ -1 +1,3 @@ -export { getGroupList } from './group'; +export * from './group'; +export * from './cards'; +export * from './myCard'; diff --git a/src/pages/HomePage/HomePage.jsx b/src/pages/HomePage/HomePage.jsx index cc11638..d44c386 100644 --- a/src/pages/HomePage/HomePage.jsx +++ b/src/pages/HomePage/HomePage.jsx @@ -10,8 +10,7 @@ import { } from '../../components'; import { useVisibleCardsEffect } from '../../utils/HomePageUtils/homePageEffects'; import CARDS_SAMPLE_DATA from '../../constants/cardsSampleData.js'; -import { getMyCard } from '../../apis/myCard.js'; -import { getCards } from '../../apis/cards.js'; +import { getCardList, getMyCard } from '../../apis'; const member_id = 5; // dummy data @@ -33,8 +32,8 @@ export default function HomePage() { async function fetchCards(member_id) { try { - const response = await getCards({ member_id: member_id }); - setCardsData(response.data.cards); + const { cards } = await getCardList(member_id); + setCardsData(cards); } catch (error) { console.error('카드 리스트를 불러오지 못했습니다.', error); }