Showing
1 changed file
with
10 additions
and
10 deletions
... | @@ -15,33 +15,33 @@ let hospital_list = []; | ... | @@ -15,33 +15,33 @@ let hospital_list = []; |
15 | router.get('/hospital', function (req, res) { | 15 | router.get('/hospital', function (req, res) { |
16 | //api | 16 | //api |
17 | let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EB%8F%99%EB%AC%BC%EB%B3%91%EC%9B%90&where=%EA%B0%95%EB%B6%81%EA%B5%AC`; | 17 | let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=%EB%8F%99%EB%AC%BC%EB%B3%91%EC%9B%90&where=%EA%B0%95%EB%B6%81%EA%B5%AC`; |
18 | - request(pet_url, function(err, response, body){ | 18 | + request(pet_url, function (err, response, body) { |
19 | - if(err) { | 19 | + if (err) { |
20 | console.log(`err => ${err}`) | 20 | console.log(`err => ${err}`) |
21 | } | 21 | } |
22 | else { | 22 | else { |
23 | - if(res.statusCode == 200) { | 23 | + if (res.statusCode == 200) { |
24 | - var result = convert.xml2json(body, {compact: true, spaces: 4}); | 24 | + var result = convert.xml2json(body, { compact: true, spaces: 4 }); |
25 | var petJson = JSON.parse(result) | 25 | var petJson = JSON.parse(result) |
26 | var itemList = petJson.response.body.items; | 26 | var itemList = petJson.response.body.items; |
27 | var numRows = itemList.item.length; //개수 | 27 | var numRows = itemList.item.length; //개수 |
28 | - for (i=0; i<numRows; i++){ | 28 | + for (i = 0; i < numRows; i++) { |
29 | // state 정상인 것만 추리기 | 29 | // state 정상인 것만 추리기 |
30 | - if (itemList.item[i].state._text == '정상'){ | 30 | + if (itemList.item[i].state._text == '정상') { |
31 | hospital_list.push(itemList.item[i]); | 31 | hospital_list.push(itemList.item[i]); |
32 | } | 32 | } |
33 | } | 33 | } |
34 | 34 | ||
35 | //테스트용 console.log | 35 | //테스트용 console.log |
36 | var titles = ''; | 36 | var titles = ''; |
37 | - for(i=0; i<hospital_list.length; i++){ | 37 | + for (i = 0; i < hospital_list.length; i++) { |
38 | - titles = titles+hospital_list[i].title._text+'\n'; | 38 | + titles = titles + hospital_list[i].title._text + '\n'; |
39 | } | 39 | } |
40 | console.log(titles); | 40 | console.log(titles); |
41 | } | 41 | } |
42 | } | 42 | } |
43 | res.send("finish"); | 43 | res.send("finish"); |
44 | }) | 44 | }) |
45 | - }); | 45 | +}); |
46 | 46 | ||
47 | - module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
47 | +module.exports = router; | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment