[Today I Learned] 12월 3주차 day6

suwoncityboyyy·2022년 12월 23일
0

json server

db와 api서버를 생성해주는 패키지
백엔드 api 서버가 구축되기 전 까지 임시로 사용하는 패키지이다
mock data를 생성하고 api 서버와 통신을 하는 임시적인 서버로 사용할 수 있다.

yarn add json-server            // json server 설치
yarn json-server --watch db.json --port 3001       // 3001번 포트에서 서버를 시작하겠다.

mock data 생성 예시

"kimchis": [
    {
      "id": 1,
      "catergory": "배추과김치",
      "name": "시원한 배추김치1",
      "description": "맛있다",
      "price": 7000,
      "image": "/images/product/kimchi_1.jpg",
      "detail-image": "/images/product/kimchi/kimchi_1-detail.png",
      "recipe-image": "/images/product/kimchi/kimchi_1-recipe.png"
    },
    {
      "id": 2,
      "catergory": "배추과김치",
      "name": "시원한 배추김치2",
      "description": "맛있다",
      "price": 8000,
      "image": "/images/product/kimchi_2.jpg",
      "detail-image": "/images/product/kimchi/kimchi_2-detail.png",
      "recipe-image": "/images/product/kimchi/kimchi_2-recipe.png"
    },

axios

http를 이용해서 서버와 통신하기 위해 사용하는 패키지

yarn add axios

[참고자료]

axios 공식문서

profile
주니어 개발자 기술노트

0개의 댓글