Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ Lib ] Json Server #35

Open
fdhhhdjd opened this issue Oct 1, 2023 · 0 comments
Open

[ Lib ] Json Server #35

fdhhhdjd opened this issue Oct 1, 2023 · 0 comments
Assignees
Labels
Feature 🪶 Function New Library Library Success ✅ Finish

Comments

@fdhhhdjd
Copy link
Owner

fdhhhdjd commented Oct 1, 2023

Json Server

Vietnamese 🇻🇳

  • Json-server là một công cụ giả mạo API dựa trên dữ liệu được lưu trữ trong các tệp JSON. Nó cho phép phát triển ứng dụng frontend mà không cần máy chủ backend thực sự, giúp bạn tập trung vào việc phát triển giao diện người dùng một cách nhanh chóng và dễ dàng.

English 🏴󠁧󠁢󠁥󠁮󠁧󠁿

  • Json-server is an API spoofing tool based on data stored in JSON files. It allows frontend application development without the need for a real backend server, allowing you to focus on user interface development quickly and easily.

Install

  • npm i -g json-server

01. Change path

image

"scripts": {
    "start": "PORT=3001 react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "server": "json-server --watch ./database/db.json  --routes ./database/routes.json --port 5000"
 }

02. Search or filter

  • http://localhost:5000/todos?completed=true
  • http://localhost:5000/todos/1
  • http://localhost:5000/todos?title_like=Book

03. Sort

http://localhost:5000/todos?_sort=title&_order=asc
http://localhost:5000/todos?_sort=id&_order=desc

04. Pagination

http://localhost:5000/todos?_page=1&_limit=10

05. filter flow condition

_gte: greater than or equal
_lte: less than or equal

http://localhost:5000/todos?id_gte=2

06. Combination

  • http://localhost:5000/todos?completed=true&_page=1&_limit=2
  • http://localhost:5000/todos?completed=false&_sort=title&_order=asc
@fdhhhdjd fdhhhdjd added Feature 🪶 Function New In Processing 🔥 pending Library Library labels Oct 1, 2023
@fdhhhdjd fdhhhdjd self-assigned this Oct 1, 2023
@fdhhhdjd fdhhhdjd added Success ✅ Finish and removed In Processing 🔥 pending labels Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature 🪶 Function New Library Library Success ✅ Finish
Projects
None yet
Development

No branches or pull requests

1 participant