현재 프론트엔드가 없는 상황에서, 개인적으로 프로젝트 때 했던 코드를 리팩토링 하고 있는 상황입니다. 그렇기 때문에 request를 받아온 것으로 가정하여 상수 데이터로 카카오 로컬 api에 요청을 보냈습니다.
javascript, Node.js, express.js, axios method
const mapEnum = [
{
y: '37.508690392047',
x: '127.05618275253',
radius: 400,
category_group_code: 'FD6',
sort: 'distance',
query: '맛집'
},
{
y: '37.908690392047',
x: '127.05618275253',
category_group_code: 'FD6',
radius: 400,
sort: 'distance',
query: '맛집'
},
{
y: '37.208690392047',
x: '127.05618275253',
category_group_code: 'FD6',
radius: 400,
sort: 'distance',
query: '맛집',
}
]
concurrent requests
const getData = async() => {
let urls = [];
for(let i=0; i<mapEnum.length; i++){
let url = `https://dapi.kakao.com/v2/local/search/keyword.json?y=${mapEnum[i].y}&x=${mapEnum[i].x}&radius=${mapEnum[i].radius}&category_group_code=${mapEnum[i].category_group_code}&sort=${mapEnum[i].sort}&query=${mapEnum[i].query}`
urls.push(url)
}
try{
const responses = await Promise.all(urls.map(url => axios.get(url, {
headers: {
'Content-Type': 'application/json;charset=UTF-8',
Authorization: 'KakaoAK process.env.KAKAO_API_KEY'
}
})))
const data = await responses.map(response => response.data.documents)
return data
}
catch(error) {
console.log(error.message)
}
}
const allData = getData()
console.log(allData)
responses
[
[
{
address_name: '서울 강남구 삼성동 156-6',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기',
distance: '3',
id: '16767932',
phone: '02-555-0041',
place_name: '삼성정육점식당',
place_url: 'http://place.map.kakao.com/16767932',
road_address_name: '서울 강남구 삼성로96길 3',
x: '127.05617022545044',
y: '37.508715374190835'
},
{
address_name: '서울 강남구 삼성동 156-6',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 치킨 > 깐부치킨',
distance: '3',
id: '12474728',
phone: '02-566-7088',
place_name: '깐부치킨 삼성점',
place_url: 'http://place.map.kakao.com/12474728',
road_address_name: '서울 강남구 삼성로96길 3',
x: '127.056184930829',
y: '37.5087180702112'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 중식 > 중국요리',
distance: '13',
id: '152462590',
phone: '02-565-7942',
place_name: '큐큐면관 삼성점',
place_url: 'http://place.map.kakao.com/152462590',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.05631728063894',
y: '37.50874413632097'
},
{
address_name: '서울 강남구 삼성동 156-6',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식',
distance: '17',
id: '25131168',
phone: '02-555-6205',
place_name: '문배동육칼 삼성직영점',
place_url: 'http://place.map.kakao.com/25131168',
road_address_name: '서울 강남구 삼성로96길 3',
x: '127.056040218624',
y: '37.5087974273658'
},
{
address_name: '서울 강남구 삼성동 156-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 패스트푸드 > 샌드위치 > 써브웨이',
distance: '18',
id: '356702055',
phone: '02-2051-2008',
place_name: '써브웨이 삼성점',
place_url: 'http://place.map.kakao.com/356702055',
road_address_name: '서울 강남구 삼성로 520',
x: '127.05598581553909',
y: '37.50864518337235'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 순대',
distance: '19',
id: '27240836',
phone: '',
place_name: '순대국포차',
place_url: 'http://place.map.kakao.com/27240836',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.056374986761',
y: '37.508775643958'
},
{
address_name: '서울 강남구 삼성동 156-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 간식',
distance: '20',
id: '1662997876',
phone: '02-552-8858',
place_name: '경성찹쌀꽈배기 삼성점',
place_url: 'http://place.map.kakao.com/1662997876',
road_address_name: '서울 강남구 삼성로 520',
x: '127.05595191771',
y: '37.5086893486635'
},
{
address_name: '서울 강남구 삼성1동 156-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 중식 > 중국요리',
distance: '22',
id: '7854904',
phone: '02-553-3939',
place_name: '리칭',
place_url: 'http://place.map.kakao.com/7854904',
road_address_name: '서울 강남구 삼성로 520',
x: '127.055927040499',
y: '37.508696568482'
},
{
address_name: '서울 강남구 삼성동 156-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 순대',
distance: '23',
id: '7881618',
phone: '02-568-9205',
place_name: '박서방순대국밥 삼성본점',
place_url: 'http://place.map.kakao.com/7881618',
road_address_name: '서울 강남구 삼성로 520',
x: '127.055922524457',
y: '37.5087073826763'
},
{
address_name: '서울 강남구 삼성동 156-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 간식 > 제과,베이커리 > 코코호도',
distance: '23',
id: '1156977975',
phone: '02-567-1303',
place_name: '코코호도 강남삼성점',
place_url: 'http://place.map.kakao.com/1156977975',
road_address_name: '서울 강남구 삼성로 520',
x: '127.055922524457',
y: '37.5087073826763'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선',
distance: '23',
id: '27598883',
phone: '02-552-5569',
place_name: '오징어청춘 삼성점',
place_url: 'http://place.map.kakao.com/27598883',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.05641571597585',
y: '37.508791842596786'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선 > 회',
distance: '23',
id: '1751054299',
phone: '02-552-5569',
place_name: '동어동락 본점',
place_url: 'http://place.map.kakao.com/1751054299',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.056406682665',
y: '37.5088116690134'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 아시아음식 > 동남아음식 > 베트남음식',
distance: '23',
id: '464620639',
phone: '02-557-6660',
place_name: '반포식스 포스코사거리점',
place_url: 'http://place.map.kakao.com/464620639',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.056406682665',
y: '37.5088116690134'
},
{
address_name: '서울 강남구 삼성동 156-7',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기 > 갈비',
distance: '26',
id: '27324164',
phone: '02-569-0903',
place_name: '마초갈비',
place_url: 'http://place.map.kakao.com/27324164',
road_address_name: '서울 강남구 삼성로96길 7',
x: '127.05640444365824',
y: '37.508842304241064'
},
{
address_name: '서울 강남구 삼성동 157-8',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 아시아음식 > 동남아음식 > 베트남음식 > 에머이',
distance: '39',
id: '1354805802',
phone: '02-556-7174',
place_name: '에머이 삼성점',
place_url: 'http://place.map.kakao.com/1354805802',
road_address_name: '서울 강남구 삼성로96길 6',
x: '127.05659876092187',
y: '37.508551186781645'
}
],
[
{
address_name: '경기 동두천시 생연동 615-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 한정식',
distance: '25',
id: '622228631',
phone: '031-866-4063',
place_name: '일미담',
place_url: 'http://place.map.kakao.com/622228631',
road_address_name: '경기 동두천시 동광로 73',
x: '127.0563104707024',
y: '37.90889284116285'
},
{
address_name: '경기 동두천시 생연동 615-23',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 술집',
distance: '37',
id: '330747180',
phone: '',
place_name: '라이브바',
place_url: 'http://place.map.kakao.com/330747180',
road_address_name: '경기 동두천시 동광로 75',
x: '127.056548109896',
y: '37.9088665998728'
},
{
address_name: '경기 동두천시 생연동 615-27',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식',
distance: '38',
id: '17191561',
phone: '031-862-2325',
place_name: '중앙길손식당',
place_url: 'http://place.map.kakao.com/17191561',
road_address_name: '경기 동두천시 동광로 69-3',
x: '127.055837430653',
y: '37.9088984721859'
},
{
address_name: '경기 동두천시 생연동 620-3',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 간식 > 제과,베이커리',
distance: '42',
id: '9062175',
phone: '031-868-3111',
place_name: '유재학빨간풍차 과자점',
place_url: 'http://place.map.kakao.com/9062175',
road_address_name: '경기 동두천시 동광로 76',
x: '127.056665067239',
y: '37.9086494162646'
},
{
address_name: '경기 동두천시 생연동 615-29',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 술집 > 호프,요리주점',
distance: '53',
id: '779505768',
phone: '',
place_name: '타임머신',
place_url: 'http://place.map.kakao.com/779505768',
road_address_name: '경기 동두천시 동광로 65',
x: '127.055573486091',
y: '37.908723814088'
},
{
address_name: '경기 동두천시 생연동 488-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기',
distance: '94',
id: '15980159',
phone: '',
place_name: '대패삼겹살',
place_url: 'http://place.map.kakao.com/15980159',
road_address_name: '경기 동두천시 동광로 80',
x: '127.057251905736',
y: '37.9087572454855'
},
{
address_name: '경기 동두천시 생연동 611-78',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 술집 > 호프,요리주점',
distance: '95',
id: '1157292426',
phone: '',
place_name: '셀리의법칙',
place_url: 'http://place.map.kakao.com/1157292426',
road_address_name: '경기 동두천시 동광로 62',
x: '127.055120744554',
y: '37.9085005930145'
},
{
address_name: '경기 동두천시 생연동 611-76',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 일식 > 돈까스,우동',
distance: '102',
id: '685809887',
phone: '',
place_name: '리가돈까스',
place_url: 'http://place.map.kakao.com/685809887',
road_address_name: '경기 동두천시 중앙로 306',
x: '127.055014031767',
y: '37.908737591062'
},
{
address_name: '경기 동두천시 생연동 613-44',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 찌개,전골',
distance: '106',
id: '11686680',
phone: '031-865-3324',
place_name: '호수식당',
place_url: 'http://place.map.kakao.com/11686680',
road_address_name: '경기 동두천시 중앙로 312',
x: '127.05512806336948',
y: '37.909165485810185'
},
{
address_name: '경기 동두천시 생연동 621-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식',
distance: '106',
id: '16101464',
phone: '031-864-7443',
place_name: '하누옥',
place_url: 'http://place.map.kakao.com/16101464',
road_address_name: '경기 동두천시 동광로81번길 3',
x: '127.057265838911',
y: '37.9091284273746'
},
{
address_name: '경기 동두천시 생연동 611-75',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 술집',
distance: '109',
id: '21299148',
phone: '',
place_name: '여울목',
place_url: 'http://place.map.kakao.com/21299148',
road_address_name: '경기 동두천시 중앙로 304',
x: '127.054963810026',
y: '37.9084844494224'
},
{
address_name: '경기 동두천시 생연동 615-38',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 찌개,전골',
distance: '114',
id: '150821595',
phone: '031-858-1731',
place_name: '세종부대찌개',
place_url: 'http://place.map.kakao.com/150821595',
road_address_name: '경기 동두천시 중앙로 314',
x: '127.05512588187493',
y: '37.9092898170117'
},
{
address_name: '경기 동두천시 생연동 612-2',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 간식 > 닭강정 > 인생닭강정',
distance: '119',
id: '707676968',
phone: '031-866-4253',
place_name: '인생닭강정 동두천중앙점',
place_url: 'http://place.map.kakao.com/707676968',
road_address_name: '경기 동두천시 중앙로 302',
x: '127.054918191333',
y: '37.9083042820245'
},
{
address_name: '경기 동두천시 생연동 551-47',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 술집',
distance: '120',
id: '18630367',
phone: '',
place_name: '아리랑',
place_url: 'http://place.map.kakao.com/18630367',
road_address_name: '경기 동두천시 동광로 83',
x: '127.05748636130795',
y: '37.90902471139001'
},
{
address_name: '경기 동두천시 생연동 612-2',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 중식 > 중국요리',
distance: '121',
id: '16663971',
phone: '',
place_name: '영풍각',
place_url: 'http://place.map.kakao.com/16663971',
road_address_name: '경기 동두천시 중앙로 302',
x: '127.05489998676148',
y: '37.908289875421616'
}
],
[
{
address_name: '경기 화성시 능동 1131',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 분식',
distance: '141',
id: '1507965167',
phone: '031-8015-1800',
place_name: '분식또와',
place_url: 'http://place.map.kakao.com/1507965167',
road_address_name: '경기 화성시 동탄숲속로 68',
x: '127.054924740888',
y: '37.2079051721732'
},
{
address_name: '경기 화성시 능동 1131',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 치킨 > 치킨매니아',
distance: '150',
id: '20438059',
phone: '031-613-9343',
place_name: '치킨매니아 능동점',
place_url: 'http://place.map.kakao.com/20438059',
road_address_name: '경기 화성시 동탄숲속로 66',
x: '127.05472990980401',
y: '37.207984554802366'
},
{
address_name: '경기 화성시 능동 449',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 아시아음식 > 동남아음식 > 베트남음식',
distance: '192',
id: '1603328172',
phone: '031-232-3492',
place_name: '호아퐁 능동본점',
place_url: 'http://place.map.kakao.com/1603328172',
road_address_name: '경기 화성시 여울로 158-60',
x: '127.05733156925442',
y: '37.21015575680293'
},
{
address_name: '경기 화성시 능동 449',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선 > 게,대게',
distance: '194',
id: '1575515822',
phone: '031-238-1117',
place_name: '용용대게',
place_url: 'http://place.map.kakao.com/1575515822',
road_address_name: '경기 화성시 여울로 158-60',
x: '127.057328209356',
y: '37.2101818888866'
},
{
address_name: '경기 화성시 능동 508-4',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 간식 > 제과,베이커리',
distance: '201',
id: '1391503153',
phone: '070-4159-8114',
place_name: '페이브 능동점',
place_url: 'http://place.map.kakao.com/1391503153',
road_address_name: '경기 화성시 동탄숲속로 63-1',
x: '127.05392506106',
y: '37.2088499324421'
},
{
address_name: '경기 화성시 능동 508-4',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 양식 > 피자',
distance: '204',
id: '21506534',
phone: '',
place_name: '익스트림피자 농민마트화성점',
place_url: 'http://place.map.kakao.com/21506534',
road_address_name: '경기 화성시 동탄숲속로 63-1',
x: '127.05388219822527',
y: '37.20877336265576'
},
{
address_name: '경기 화성시 능동 451-2',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선',
distance: '227',
id: '13137298',
phone: '031-223-5800',
place_name: '생태명가 능동점',
place_url: 'http://place.map.kakao.com/13137298',
road_address_name: '경기 화성시 동탄지성로 169',
x: '127.05688695924405',
y: '37.210661460332'
},
{
address_name: '경기 화성시 능동 448-1',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기 > 갈비',
distance: '228',
id: '14828031',
phone: '031-225-4295',
place_name: '도란도란',
place_url: 'http://place.map.kakao.com/14828031',
road_address_name: '경기 화성시 동탄지성로 163',
x: '127.057652811047',
y: '37.2103835666012'
},
{
address_name: '경기 화성시 능동 452-3',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선',
distance: '233',
id: '1126820413',
phone: '031-222-3244',
place_name: '꾸메뜨락직화쭈꾸미 능동점',
place_url: 'http://place.map.kakao.com/1126820413',
road_address_name: '경기 화성시 동탄지성로 173',
x: '127.05659863714',
y: '37.2107661202656'
},
{
address_name: '경기 화성시 능동 508-5',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식',
distance: '241',
id: '481025280',
phone: '031-221-1827',
place_name: '명가만두전골',
place_url: 'http://place.map.kakao.com/481025280',
road_address_name: '경기 화성시 여울로 116',
x: '127.053614527177',
y: '37.2094015162646'
},
{
address_name: '경기 화성시 능동 484-1',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식',
distance: '257',
id: '1001474743',
phone: '031-224-3006',
place_name: '두코 동탄점',
place_url: 'http://place.map.kakao.com/1001474743',
road_address_name: '경기 화성시 동탄숲속로 63-24',
x: '127.054498585646',
y: '37.2105796866256'
},
{
address_name: '경기 화성시 능동 1132',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선 > 회',
distance: '258',
id: '21855348',
phone: '',
place_name: '동해수산',
place_url: 'http://place.map.kakao.com/21855348',
road_address_name: '경기 화성시 동탄숲속로 98',
x: '127.058168422137',
y: '37.2069881563097'
},
{
address_name: '경기 화성시 능동 528-3',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 해물,생선 > 황금코다리',
distance: '259',
id: '368395411',
phone: '031-223-5504',
place_name: '황금코다리 동탄점',
place_url: 'http://place.map.kakao.com/368395411',
road_address_name: '경기 화성시 여울로 120',
x: '127.05354037831738',
y: '37.209688984870084'
},
{
address_name: '경기 화성시 능동 460-21',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기 > 갈비',
distance: '272',
id: '14589547',
phone: '',
place_name: '황진이정육식당',
place_url: 'http://place.map.kakao.com/14589547',
road_address_name: '경기 화성시 동탄지성로 179',
x: '127.056098722562',
y: '37.2111447991338'
},
{
address_name: '경기 화성시 능동 460-21',
category_group_code: 'FD6',
category_group_name: '음식점',
category_name: '음식점 > 한식 > 육류,고기',
distance: '274',
id: '24163853',
phone: '031-222-1773',
place_name: '양촌리청보리한우',
place_url: 'http://place.map.kakao.com/24163853',
road_address_name: '경기 화성시 동탄지성로 179',
x: '127.05606606535498',
y: '37.21116283559764'
}
]
]