
기존에 개발했던 Korean Dummy JSON API를 더욱 편리하게 사용할 수 있도록, 비동기 API 호출 없이 바로 더미 데이터를 사용할 수 있는 Korean Dummy JSON Fetcher 라이브러리를 새롭게 출시했습니다! 🎉
💡 참고사항
PATCH, PUT, POST, DELETE API는 실제 서버 데이터를 변경하지 않고, 성공적인 모의(mock) 응답만 반환합니다. 테스트와 개발에 최적화되어 있어요!
총 9개의 다양한 리소스를 제공합니다:
| 리소스 | 설명 | 개수 |
|---|---|---|
| 👥 users | 유저 정보 | 20명 |
| 📝 posts | 게시물 | 100개 |
| 💬 comments | 댓글 | 500개 |
| ✅ todos | 할 일 목록 | 200개 |
| 📚 books | 책 정보 | 100개 |
| ⭐ reviews | 도서 리뷰 | 500개 |
| 🔐 auth | 로그인 및 인증 | - |
| 🖼️ image | 동적 이미지 생성 | - |
| 📄 lorem | 한글 로렘 입숨 | - |
# npm
npm install korean-dummy-json-fetcher
# yarn
yarn add korean-dummy-json-fetcher
# pnpm
pnpm add korean-dummy-json-fetcher
<!-- unpkg -->
<script src="https://unpkg.com/korean-dummy-json-fetcher@1.1.0/dist/index.min.js"></script>
<!-- jsdelivr -->
<script src="https://cdn.jsdelivr.net/npm/korean-dummy-json-fetcher@1.1.0/dist/index.min.js"></script>
import {
getUsers,
getUser,
createUser,
patchUser,
putUser,
deleteUser,
} from "korean-dummy-json-fetcher";
async function fetchUsers() {
// 📋 전체 사용자 목록
const users = await getUsers();
// 📄 페이지네이션
const usersPage = await getUsers({ page: 1, limit: 10 });
// 👤 특정 사용자 조회
const user = await getUser({ id: 1 });
// ➕ 새 사용자 생성
const newUser = await createUser({
username: "홍길동",
email: "hong@example.com",
phone: "010-1234-5678",
address: "서울시 강남구"
});
// ✏️ 사용자 정보 일부 수정
const updatedUser = await patchUser(1, {
username: "김철수"
});
// 🔄 사용자 정보 전체 교체
const replacedUser = await putUser(1, {
username: "이영희",
email: "lee@example.com",
phone: "010-9876-5432",
address: "부산시 해운대구"
});
// 🗑️ 사용자 삭제
await deleteUser({ id: 1 });
}
import {
getTodos,
getTodo,
createTodo,
patchTodo,
putTodo,
deleteTodo,
} from "korean-dummy-json-fetcher";
async function fetchTodos() {
// 📋 전체 할 일 목록
const todos = await getTodos();
// 👤 특정 사용자의 할 일만 조회
const userTodos = await getTodos({ userId: 1 });
// ➕ 새 할 일 추가
const newTodo = await createTodo({
userId: 1,
content: "Korean Dummy JSON Fetcher 블로그 포스팅 작성하기",
completed: false
});
// ✅ 할 일 완료 처리
await patchTodo(1, { completed: true });
}
import {
getPosts,
getPost,
createPost,
patchPost,
putPost,
deletePost,
} from "korean-dummy-json-fetcher";
async function fetchPosts() {
// 📋 전체 게시글 목록
const posts = await getPosts();
// 👤 특정 사용자의 게시글만 조회
const userPosts = await getPosts({ userId: 1 });
// ➕ 새 게시글 작성
const newPost = await createPost({
userId: 1,
title: "Korean Dummy JSON Fetcher 사용 후기",
content: "정말 편리한 라이브러리입니다!",
imgUrl: "https://example.com/thumbnail.jpg"
});
}
import {
getComments,
getComment,
createComment,
patchComment,
putComment,
deleteComment,
} from "korean-dummy-json-fetcher";
async function fetchComments() {
// 📋 전체 댓글 목록
const comments = await getComments();
// 📄 페이지네이션
const commentsPage = await getComments({ page: 1, limit: 10 });
// 📝 특정 게시글의 댓글만 조회
const postComments = await getComments({ postId: 1 });
// 👤 특정 사용자의 댓글만 조회
const userComments = await getComments({ userId: 1 });
// 🔍 특정 댓글 조회
const comment = await getComment({ id: 1 });
// ➕ 새 댓글 작성
const newComment = await createComment({
userId: 1,
postId: 1,
content: "정말 유용한 게시글이네요!"
});
// ✏️ 댓글 일부 수정
const updatedComment = await patchComment(1, {
content: "수정된 댓글 내용"
});
// 🔄 댓글 전체 수정
const replacedComment = await putComment(1, {
content: "완전히 새로운 댓글 내용"
});
// 🗑️ 댓글 삭제
await deleteComment({ id: 1 });
}
import {
getBooks,
getBook,
createBook,
patchBook,
putBook,
deleteBook,
} from "korean-dummy-json-fetcher";
async function fetchBooks() {
// 📋 전체 책 목록
const books = await getBooks();
// 📄 페이지네이션
const booksPage = await getBooks({ page: 1, limit: 10 });
// 🔍 특정 책 조회
const book = await getBook({ id: 1 });
// ➕ 새 책 등록
const newBook = await createBook({
author: "김작가",
genre: "소설",
title: "새로운 이야기",
publicationDate: "2024-01-01",
totalPage: 350
});
// ✏️ 책 정보 일부 수정
const updatedBook = await patchBook(1, {
title: "수정된 도서 제목"
});
// 🔄 책 정보 전체 수정
const replacedBook = await putBook(1, {
author: "이작가",
genre: "에세이",
title: "완전히 새로운 책",
publicationDate: "2024-12-01",
totalPage: 200
});
// 🗑️ 책 삭제
await deleteBook({ id: 1 });
}
import {
getReviews,
getReview,
createReview,
patchReview,
putReview,
deleteReview,
} from "korean-dummy-json-fetcher";
async function fetchReviews() {
// 📋 전체 리뷰 목록
const reviews = await getReviews();
// 📄 페이지네이션
const reviewsPage = await getReviews({ page: 1, limit: 10 });
// 📚 특정 도서의 리뷰만 조회
const bookReviews = await getReviews({ bookId: 1 });
// 👤 특정 사용자의 리뷰만 조회
const userReviews = await getReviews({ userId: 1 });
// 🔍 특정 리뷰 조회
const review = await getReview({ id: 1 });
// ➕ 새 리뷰 작성
const newReview = await createReview({
userId: 1,
bookId: 1,
rating: 5,
content: "정말 감동적인 책이었습니다!"
});
// ✏️ 리뷰 일부 수정
const updatedReview = await patchReview(1, {
content: "수정된 리뷰 내용"
});
// 🔄 리뷰 전체 수정
const replacedReview = await putReview(1, {
rating: 4,
content: "다시 읽어보니 4점이 적당한 것 같네요"
});
// 🗑️ 리뷰 삭제
await deleteReview({ id: 1 });
}
import {
login,
getAuthUser,
refreshAccessToken,
} from "korean-dummy-json-fetcher";
async function fetchAuth() {
// 🔑 로그인
const { accessToken, refreshToken } = await login({
id: "test",
password: "1234"
});
// 👤 토큰으로 사용자 정보 조회
const user = await getAuthUser({ accessToken });
// 🔄 액세스 토큰 갱신
const { accessToken: newToken } = await refreshAccessToken({
refreshToken
});
}
import { getImage } from "korean-dummy-json-fetcher";
// 🖼️ 커스텀 이미지 생성
const imageData = getImage({
size: "400x300",
text: "안녕하세요!",
bgColor: "007bff",
textColor: "ffffff",
ext: "png"
});
import { getLorem } from "korean-dummy-json-fetcher";
async function fetchLorem() {
// 📝 한글 더미 텍스트 생성
const lorem = await getLorem({
mode: "p", // 문단 모드
count: 3, // 3개 문단
length: 150 // 각 문단당 150자
});
console.log(lorem);
}
import React, { useEffect, useState } from 'react';
import { getUsers, getPosts } from 'korean-dummy-json-fetcher';
function BlogApp() {
const [users, setUsers] = useState([]);
const [posts, setPosts] = useState([]);
useEffect(() => {
async function loadData() {
// 🚀 즉시 데이터 로드 - API 호출 불필요!
const userData = await getUsers({ limit: 5 });
const postData = await getPosts({ limit: 10 });
setUsers(userData.users);
setPosts(postData.posts);
}
loadData();
}, []);
return (
<div>
<h2>👥 사용자 목록</h2>
{users.map(user => (
<div key={user.id}>
<p><strong>ID:</strong> {user.id}</p>
<p><strong>이름:</strong> {user.username}</p>
<p><strong>이메일:</strong> {user.email}</p>
<p><strong>전화번호:</strong> {user.phone}</p>
<p><strong>주소:</strong> {user.address}</p>
<p><strong>가입일:</strong> {user.createdAt}</p>
<hr />
</div>
))}
<h2>📝 최신 게시글</h2>
{posts.map(post => (
<article key={post.id}>
<p><strong>게시글 ID:</strong> {post.id}</p>
<p><strong>작성자 ID:</strong> {post.userId}</p>
<h3><strong>제목:</strong> {post.title}</h3>
<p><strong>내용:</strong> {post.content}</p>
<p><strong>이미지 URL:</strong> {post.imgUrl}</p>
<p><strong>작성일:</strong> {post.createdAt}</p>
<hr />
</article>
))}
</div>
);
}
한국어 더미 데이터가 필요한 프로젝트에서 이 라이브러리가 도움이 되었으면 좋겠습니다. 프론트엔드 개발, API 테스트, 프로토타이핑 등 다양한 용도로 활용해보세요!
API Resource별 자세한 내용이 궁금하다면 Korean Dummy JSON Docs 페이지를 참고해주세요.
이 라이브러리가 도움이 되셨다면 많은 개발자분들이 사용할 수 있도록 주변에 공유해주세요!
궁금한 점이나 개선사항, 버그가 있다면 댓글 혹은 아래 이메일로 언제든 연락주세요 .
📧 이메일: dark9737@gmail.com
💚 도움이 되셨다면 댓글, 좋아요 부탁드려요!