Suyeon Jung

Complete shop category

......@@ -181,10 +181,9 @@ router.post('/', function(req, res) {
router.get('/food', function(req, res) {
// 맛집 리스트 조회
let sigun_cd = SIGUN_CODE;
let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt';
let fastfood_url = 'https://openapi.gg.go.kr/Genrestrtfastfood'
let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}&Type=json`;
let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}&Type=json`;
request({
url: url + qs,
......@@ -295,23 +294,34 @@ router.get('/park', function(req, res) {
});
router.get('/shop', function(req, res) {
let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY;
let sigun_cd = SIGUN_CODE;
let mallnum = 0;
let url = 'https://openapi.gg.go.kr/MrktStoreM';
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}`;
let shop_url = 'https://openapi.gg.go.kr/MrktStoreM';
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
request({
url: url + qs,
url: shop_url + qs,
method: 'GET'
}, function(err, response, body) {
var shop_result = JSON.parse(body);
if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
mallnum = shop_result.MrktStoreM[0].head[0].list_total_count;
console.log(mallnum + "개의 쇼핑몰이 존재합니다.");
res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다.");
} else {
res.send("쇼핑몰이 없습니다.");
if (!err && res.statusCode == 200) {
let shop_result = JSON.parse(body);
let shops = [];
for (let i = 0; i < shop_result.MrktStoreM[1].row.length; i++) {
shop = shop_result.MrktStoreM[1].row[i];
// 폐업인 지점 제외
console.log('shop', shop);
shops.push(shop);
}
res.render('shop_result', { shops: shops });
}
// var shop_result = JSON.parse(body);
// if (shop_result.MrktStoreM[0].head[1].RESULT.CODE == 'INFO-000') {
// mallnum = shop_result.MrktStoreM[0].head[0].list_total_count;
// console.log(mallnum + "개의 쇼핑몰이 존재합니다.");
// res.send(String(mallnum) + "개의 쇼핑몰이 존재합니다.");
// } else {
// res.send("쇼핑몰이 없습니다.");
// }
})
});
......
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>✍️ 결과 페이지</title>
</head>
<body>
<h1>🛍 쇼핑몰 현황(시장, 상가, 마트) </h1>
<%for (var i =0; i <shops.length; i++){%>
<li>
<%=shops[i].MARKET_NM%>
</li>
<%}%>
<h3>총 쇼핑몰 개수 :
<%=shops.length%>
</h3>
</body>
</html>
\ No newline at end of file