Showing
2 changed files
with
29 additions
and
1 deletions
... | @@ -183,6 +183,7 @@ router.get('/food', function(req, res) { | ... | @@ -183,6 +183,7 @@ router.get('/food', function(req, res) { |
183 | let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; | 183 | let GYEONGI_API_KEY = process.env.GYEONGGI_APIKEY; |
184 | let sigun_cd = SIGUN_CODE; | 184 | let sigun_cd = SIGUN_CODE; |
185 | let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt'; | 185 | let url = 'https://openapi.gg.go.kr/PlaceThatDoATasteyFoodSt'; |
186 | + let fastfood_url = 'https://openapi.gg.go.kr/Genrestrtfastfood' | ||
186 | let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}&Type=json`; | 187 | let qs = `?KEY=${GYEONGI_API_KEY}&SIGUN_CD=${sigun_cd}&Type=json`; |
187 | 188 | ||
188 | request({ | 189 | request({ |
... | @@ -201,7 +202,25 @@ router.get('/food', function(req, res) { | ... | @@ -201,7 +202,25 @@ router.get('/food', function(req, res) { |
201 | } | 202 | } |
202 | console.log('food_result', food_result); | 203 | console.log('food_result', food_result); |
203 | console.log('store_names', store_names); | 204 | console.log('store_names', store_names); |
204 | - res.render('result', { store_names: store_names }); | 205 | + request({ |
206 | + url: fastfood_url + qs, | ||
207 | + method: 'GET' | ||
208 | + }, function(err, response, body) { | ||
209 | + if (!err && res.statusCode == 200) { | ||
210 | + let fast_food_result = JSON.parse(body); | ||
211 | + let fast_store_names = [] | ||
212 | + for (let i = 0; i < fast_food_result.Genrestrtfastfood[1].row.length; i++) { | ||
213 | + fast_store_name = fast_food_result.Genrestrtfastfood[1].row[i]; | ||
214 | + if (fast_store_name['BSN_STATE_NM'] != '폐업') { | ||
215 | + console.log('fast_store_name', fast_store_name); | ||
216 | + fast_store_names.push(fast_store_name); | ||
217 | + } | ||
218 | + } | ||
219 | + res.render('result', { store_names: store_names, fast_store_names: fast_store_names }); | ||
220 | + } | ||
221 | + | ||
222 | + }) | ||
223 | + | ||
205 | } | 224 | } |
206 | }); | 225 | }); |
207 | }); | 226 | }); | ... | ... |
... | @@ -18,6 +18,15 @@ | ... | @@ -18,6 +18,15 @@ |
18 | <%=store_names.length%> | 18 | <%=store_names.length%> |
19 | </h3> | 19 | </h3> |
20 | <h1>🍔 패스트푸드점 현황 </h1> | 20 | <h1>🍔 패스트푸드점 현황 </h1> |
21 | + <%for (var i =0; i <fast_store_names.length; i++){%> | ||
22 | + <li> | ||
23 | + <%=fast_store_names[i].BIZPLC_NM%> | ||
24 | + </li> | ||
25 | + | ||
26 | + <%}%> | ||
27 | + <h3>총 맛집 개수 : | ||
28 | + <%=fast_store_names.length%> | ||
29 | + </h3> | ||
21 | 30 | ||
22 | </body> | 31 | </body> |
23 | 32 | ... | ... |
-
Please register or login to post a comment