

const API_PATH = {
FAVORITE_TRAVELS: `${BASE_PATH.TRAVELS}/favorite`,
SIGNATURE_PREVIEW: `${BASE_PATH.SIGNATURE}/preview`,
};


import { axios, axiosWithToken } from '../api';
import { API_PATH } from '@/constants/path';
// 토큰이 필요없는 경우 axios를 쓰면됩니다.
const getSignaturePreview = () => {
return axios.get(API_PATH.SIGNATURE_PREVIEW);
};
// 토큰이 필요한 경우 axios대신, axiosWithToken을 사용하면 됩니다.
export { getSignaturePreview };


import { HttpResponse, http } from 'msw';
import { baseURL } from '@/apis/api';
import { API_PATH } from '@/constants/path';
export const PreveiewHandlers = [
http.get(`${baseURL}${API_PATH.SIGNATURE_PREVIEW}`, (req, res, ctx) => {
const previewData = [
{
id: 1,
userImgUrl: '<https://i.ibb.co/JdGMYqf/Group-1000000912.png>',
date: '23 / 10 / 11',
previewUrl:
'<https://i.ibb.co/D1bwz3j/Kakao-Talk-20231203-204945606.png>" alt="Kakao-Talk-20231203-204945606',
title: '우리 동글이와 함꼐한, 강릉 1박 2일',
heart: 3012,
},
{
id: 2,
userImgUrl: '<https://i.ibb.co/JdGMYqf/Group-1000000912.png>',
date: '23 / 10 / 11',
previewUrl:
'<https://i.ibb.co/D1bwz3j/Kakao-Talk-20231203-204945606.png>" alt="Kakao-Talk-20231203-204945606',
title: '우리 동글이와 함꼐한, 강릉 1박 2일',
heart: 3012,
},
{
id: 3,
userImgUrl: '<https://i.ibb.co/JdGMYqf/Group-1000000912.png>',
date: '23 / 10 / 11',
previewUrl:
'<https://i.ibb.co/D1bwz3j/Kakao-Talk-20231203-204945606.png>" alt="Kakao-Talk-20231203-204945606',
title: '우리 동글이와 함꼐한, 강릉 1박 2일',
heart: 3012,
},
{
id: 4,
userImgUrl: '<https://i.ibb.co/JdGMYqf/Group-1000000912.png>',
date: '23 / 10 / 11',
previewUrl:
'<https://i.ibb.co/D1bwz3j/Kakao-Talk-20231203-204945606.png>" alt="Kakao-Talk-20231203-204945606',
title: '우리 동글이와 함꼐한, 강릉 1박 2일',
heart: 3012,
},
];
return HttpResponse.json(previewData);
}),
];

import { PreveiewHandlers } from './previewHandler';
import { travelHandlers } from './travel-place';
export const handlers = [...travelHandlers, ...PreveiewHandlers];
사용할 컴포넌트 가서 만든 api/request import 해주고 데이터 쓰면 됨
import { getSignaturePreview } from '@/apis/request/preview';
const [data, setData] = useState([]);
const getData = async () => {
try {
const res = await getSignaturePreview();
const mockData = res.data;
setData(mockData);
console.log(data);
} catch (e) {
console.log(e);
}
};
useEffect(() => {
getData();
}, []);