: 연락처 목록 조회 기능. 페이지 번호가 0인 경우 전체 데이터 조회
{
"pageno": 1,
"pagesize": 2,
"totalcount": 103,
"contacts": [
{
"no": "5c7129de4840822eb4d2c26a",
"name": "트럼프",
"tel": "010-2222-3333",
"address": "서울시",
"photo": "http://localhost:3000/photos/LUgMVPm0Q"
},
{
"no": "5c7129de4840822eb4d2c269",
"name": "샌더스",
"tel": "010-2222-3332",
"address": "서울시",
"photo": "http://localhost:3000/photos/nOF1rSRft"
}
]
}
: 특정 연락처 한건 조회
{
"name": "샌더스",
"tel": "010-2222-3332",
"address": "서울시",
"photo": "http://localhost:3000/photos/nOF1rSRft",
"no": "5c7129de4840822eb4d2c269"
}
{
"status": "fail",
"message": "연락처 정보 없음"
}
: 이름을 이용해 연락처 검색
[
{
"no": "5c7129c600c812065c3964e0",
"name": "Rachel Johnson",
"tel": "010-3456-8225",
"address": "서울시",
"photo": "http://localhost:3000/photos/YKPoqQqkkKu"
},
{
"no": "5c7129c600c812065c396506",
"name": "Rosebud Jones",
"tel": "010-3456-8263",
"address": "서울시",
"photo": "http://localhost:3000/photos/4wXGJU4i1G"
}
]
: 새로운 연락처 추가(초기사진은 noimage.jpg로 설정함)
: 사진을 수정하려면 POST /contacts/:no/photo API를 호출해야 함.
{
"name":"강감찬",
"tel":"010-2222-3339",
"address":"서울시"
}
name=....&tel=....&address=....
{
"status": "ok",
"message": "연락처 추가 성공",
"no": "5c713b495489753ce808e673"
}
{
"status": "fail",
"message": "[에러메시지]"
}
: 기존 연락처 정보 변경
PUT /contacts/5c7144886484aa140412f884
{
"name":"강감찬",
"tel":"010-2222-3339",
"address":"서울시"
}
no=...&name=....&tel=....&address=....
{
"status": "success",
"message": "업데이트 성공",
"no": "5c7144886484aa140412f884"
}
{
"status": "fail",
"message": "[에러메시지]"
}
: 기존 연락처 삭제
{
"status": "success",
"message": "삭제 성공",
"no" : "5c7144886484aa140412f884"
}
{
"status": "fail",
"message": "[에러메시지]"
}
: 여러 건의 연락처를 한번에 추가함
[
{ "name":"오바마", "tel":"010-2222-3339", "address":"서울시" },
{ "name":"샌더스", "tel":"010-2222-3332", "address":"서울시" },
{ "name":"트럼프", "tel":"010-2222-3333", "address":"서울시" }
]
{
"status": "ok",
"message": "3건의 데이터 추가 성공",
"no": [
"5c7144886484aa140412f882",
"5c7144886484aa140412f883",
"5c7144886484aa140412f884"
]
}
{
"status": "fail",
"message": "[에러메시지]"
}
: 연락처 정보의 사진을 업로드하고 변경함
{
"status": "success",
"message": "사진 변경 성공 => photo_id : ihAmNA6fM",
"no": "5c7144886484aa140412f884"
}
{
"status": "fail",
"message": "[에러메시지]"
}
//자세한 예제는 https://github.com/mzabriskie/axios/blob/master/examples/upload/index.html 참조
import axios from 'axios';
var data = new FormData();
data.append('photo', document.getElementById('photo').files[0]);
axios.post('/api/contacts/' + no + '/photo', data)
.then((response) => {
console.log(response);
})
.catch((ex) => {
console.log('updatePhoto failed', ex);
});
: 1초의 지연시간 후 연락처 목록 응답. 페이지 번호가 0인 경우 전체 데이터 조회
{
"pageno": 1,
"pagesize": 2,
"totalcount": 106,
"contacts": [
{
"no": "5c7144886484aa140412f884",
"name": "모모",
"tel": "010-9999-9999",
"address": "제주",
"photo": "http://localhost:3000/photos/kVUsltfiG"
},
{
"no": "5c7144886484aa140412f883",
"name": "정연",
"tel": "010-2222-3332",
"address": "서울시",
"photo": "http://localhost:3000/photos/noimage"
}
]
}
: 이름을 이용해 연락처 검색(1초의 지연시간 발생)
[
{
"no": "5c7129c600c812065c3964e0",
"name": "Rachel Johnson",
"tel": "010-3456-8225",
"address": "서울시",
"photo": "http://localhost:3000/photos/YKPoqQqkkKu"
},
{
"no": "5c7129c600c812065c396506",
"name": "Rosebud Jones",
"tel": "010-3456-8263",
"address": "서울시",
"photo": "http://localhost:3000/photos/4wXGJU4i1G"
}
]