8.1 상품 등록
API
POST /product
JavaScript
복사
method, 전송 url
Req
{
"product":{
"itemName": String,
"price": Number,//1원 이상
"link": String,
"itemImage": String
}
}
JSON
복사
body(json)
{
"Authorization" : "Bearer {token}",
"Content-type" : "application/json"
}
JSON
복사
header
Res
// SUCCESS
{
"product": {
"id": String,
"itemName": String,
"price": Number,
"link": String,
"itemImage": String,
"author": {
"_id": "작성자 id",
"username": "2",
"accountname": "2",
"intro": "2",
"image": "2",
"following": [],
"follower": [
"팔로워 한 사용자의 id"
],
"followerCount": 1,
"followingCount": 0
}
}
}
// FAIL
// itemName, price, link, itemImage 중 하나라도 입력하지 않았을 때
필수 입력사항을 입력해주세요.
// price를 String으로 입력했을 때
가격은 숫자로 입력하셔야 합니다.
JSON
복사
8.2 상품 리스트
API
GET /product/:accountname
// paging limit skip
GET /product/:accountname/?limit=Number&skip=Number
JavaScript
복사
method, 전송 url
Req
{
"Authorization" : "Bearer {token}",
"Content-type" : "application/json"
}
JSON
복사
header
Res
// SUCCESS
// 상품이 있을 때
{
"data" : Number,
"product": [
{
"id": String,
"itemName": String,
"price": Number,
"link": String,
"itemImage": String,
"author": {
"_id": "작성자 id",
"username": "2",
"accountname": "2",
"intro": "2",
"image": "2",
"following": [],
"follower": [
"팔로워 한 사용자의 id"
],
"followerCount": 1,
"followingCount": 0
}
}
]
}
// 상품이 없을 때
{
"data" : 0,
"product": []
}
JSON
복사
8.3 상품 상세
API
GET /product/detail/:product_id
JavaScript
복사
Req
{
"Authorization" : "Bearer {token}",
"Content-type" : "application/json"
}
JSON
복사
header
Res
// SUCCESS
{
"product":{
"id": String,
"itemName": String,
"price": Number,
"link": String,
"itemImage": String,
"author": {
"_id": "작성자 id",
"username": "2",
"accountname": "2",
"intro": "2",
"image": "2",
"following": [],
"follower": [
"팔로워 한 사용자의 id"
],
"followerCount": 1,
"followingCount": 0
}
}
}
JSON
복사
8.4 상품 수정
API
PUT /product/:product_id
JavaScript
복사
method, 전송 url
Req
{
"product": {
"itemName": String,
"price": Number,
"link": String,
"itemImage": String
}
}
}
JSON
복사
body(json)
{
"Authorization" : "Bearer {token}",
"Content-type" : "application/json"
}
JSON
복사
header
Res
// SUCCESS
{
"product": {
"id": String,
"itemName": String,
"price": Number,
"link": String,
"itemImage": String,
"author": {
"_id": "작성자 id",
"username": "2",
"accountname": "2",
"intro": "2",
"image": "2",
"following": [],
"follower": [
"팔로워 한 사용자의 id"
],
"followerCount": 1,
"followingCount": 0
}
}
}
// FAIL
// 상품이 없을 때
등록된 상품이 없습니다.
// 상품을 등록한 사용자가 아닐 때
잘못된 요청입니다. 로그인 정보를 확인하세요.
JSON
복사
8.5 상품 삭제
API
DELETE /product/:product_id
JavaScript
복사
method, 전송 url
Req
{
"Authorization" : "Bearer {token}",
"Content-type" : "application/json"
}
JSON
복사
header
Res
// SUCCESS
삭제되었습니다.
// FAIL
// 상품이 없을 때
등록된 상품이 없습니다.
// 상품을 등록한 사용자가 아닐 때
잘못된 요청입니다. 로그인 정보를 확인하세요.
JSON
복사