Suyeon Jung

Change api from songclub to movietheater : culture result

......@@ -404,26 +404,26 @@ router.get('/safe', function(req, res) {
});
router.get('/culture', function(req, res) {
// 노래방
let sing_url = 'https://openapi.gg.go.kr/Songclub';
// 영화관
let movie_url = 'https://openapi.gg.go.kr/MovieTheater';
let qs = `?Type=json&KEY=${GYEONGI_API_KEY}&SIGUN_CD=${SIGUN_CODE}`;
request({
url: sing_url + qs,
url: movie_url + qs,
method: 'GET'
}, function(err, response, body) {
if (!err && res.statusCode == 200) {
let sing_result = JSON.parse(body);
console.log(sing_result);
let sings = [];
for (let i = 0; i < sing_result.Songclub[1].row.length; i++) {
sing = sing_result.Songclub[1].row[i];
let movie_result = JSON.parse(body);
console.log(movie_result);
let movies = [];
for (let i = 0; i < movie_result.MovieTheater[1].row.length; i++) {
movie = movie_result.MovieTheater[1].row[i];
// 폐업인 지점 제외
if (!sing['BSN_STATE_NM'].includes('폐업') && userArea(sing, 'REFINE_LOTNO_ADDR', user_dong)) {
console.log('sing', sing);
sings.push(sing);
if (!movie['BSN_STATE_NM'].includes('폐업') && userArea(movie, 'REFINE_LOTNO_ADDR', user_dong)) {
console.log('movie', movie);
movies.push(movie);
}
}
res.render('result', { category: 'culture', sings: sings, userLocation: userLocation });
res.render('result', { category: 'culture', movies: movies, userLocation: userLocation });
}
});
});
......
<h1>🎤 노래방 현황</h1>
<h1>🎬 영화관 현황</h1>
<table class="table">
<thead>
<th>사업장명</th>
<th>도로명주소</th>
</thead>
<tbody>
<%for (var i =0; i <sings.length; i++){%>
<%for (var i =0; i <movies.length; i++){%>
<tr>
<td>
<%=sings[i].BIZPLC_NM%>
<%=movies[i].BIZPLC_NM%>
</td>
<td>
<%=sings[i].REFINE_ROADNM_ADDR%>
<%=movies[i].REFINE_ROADNM_ADDR%>
</td>
</tr>
<%}%>
......@@ -19,6 +19,6 @@
</table>
<h3>총 노래방 개수 :
<%=sings.length%>
<h3>총 영화관 개수 :
<%=movies.length%>
</h3>
\ No newline at end of file
......