Skip to content

2 1. 게시글 생성

Donghoon Lee edited this page Nov 2, 2021 · 1 revision

게시글 생성

메소드 경로 짧은 설명
POST http://ServerAddress:3000/posts/write 게시글 생성

Request Header

변수 타입 설명
"token" STRING 액세스 토큰

Request Body

변수 타입 설명
"title" STRING 게시글 제목
"content" STRING 게시글 내용
"category" STRING 게시글 카테고리

요청 예시

body - JSON

{
    "title" : "게시글 제목 테스트",
    "content" : "게시글 내용 테스트",
    "category": "wanted"
}

Response 예시

Success: 게시글 생성 성공 (200)

{
    "_id",
    "authorId",
    "title",
    "category",
    "content",
    "count",
    "createdAt",
    "updatedAt",
    "postId",
    "_v"
}

fail: 입력값 미등록시 (400)

{ message: "모든 필드를 채워주세요" }

fail: 헤더 토큰 유무 (401)

{
    message: "You are not authenticated!" 
}

fail: 헤더 유효하지 않은 토큰을 입력한 경우 (403)

{
    message: "Token is not valid!"
}

fail: 서버 내부 오류 (400)

{
    "요청이 잘못되었습니다. 재검토하고 재요청할 필요가 있습니다."
}