Skip to content

Mock API 생성

Manjin Bae edited this page Apr 9, 2021 · 3 revisions

Mock API 생성

  • Postman Mock Server 사용

  • Get Test

    GET, /api/todos/

    https://446afdfc-c2bf-4c3a-8f4b-6615eb95c53e.mock.pstmn.io

    {
        "status": "success",
        "data": {
            "todos": [
                {
                    "id": 1,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",           
    								"createdAt": "1617880934"
                },
                {
                    "id": 2,
                    "title": "Legacy",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 3,
                    "title": "Facilitator",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                }
            ]
        }
    }

    GET, /api/todos/1

    {
        "status": "success",
        "data": {
            "todo": {
                "id": 1,
                "title": "Mobility",
                "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                "createdAt": "1617880934"
            }
        }
    }
  • Update Test

    PUT, /api/todos/2

    https://7718ed4e-33d1-45b1-bc90-71af2ad73091.mock.pstmn.io

    → 2nd todo를 1st todo의 필드로 수정

    {
        "status": "success",
        "data": {
            "todo": {
                "id": 2,
                "title": "Mobility",
                "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                "createdAt": "1617880934"
            }
        }
    }

    GET, /api/todos/

    {
        "status": "success",
        "data": {
            "todos": [
                {
                    "id": 1,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 2,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 3,
                    "title": "Facilitator",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                }
            ]
        }
    }
  • Delete Test

    DELETE, /api/todos/3

    https://08a4a2a5-4805-4e07-9cf7-8af898a523f2.mock.pstmn.io

    → 3rd todo 삭제

    {
        "status": "success",
        "data": {}
    }

    GET, /api/todos/

    {
        "status": "success",
        "data": {
            "todos": [
                {
                    "id": 1,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 2,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                }
            ]
        }
    }
  • Create Test

    POST, /api/todos/

    https://5a02ab69-c24e-4aac-b582-13117429781e.mock.pstmn.io

    → 1st todo의 필드와 동일한 4th todo 생성

    {
        "status": "success",
        "data": {
            "todo": {
                "id": 4,
                "title": "Mobility",
                "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                "createdAt": "1617880934"
            }
        }
    }

    GET, /api/todos/

    {
        "status": "success",
        "data": {
            "todos": [
                {
                    "id": 1,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",           
    								"createdAt": "1617880934"
                },
                {
                    "id": 2,
                    "title": "Legacy",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 3,
                    "title": "Facilitator",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",
                    "createdAt": "1617880934"
                },
                {
                    "id": 4,
                    "title": "Mobility",
                    "content": "If we bypass the driver, we can get to the SMS firewall through the haptic HTTP microchip!",           
    								"createdAt": "1617880934"
                }
            ]
        }
    }
Clone this wiki locally