오수빈

modify numRow

...@@ -13,7 +13,8 @@ let user_longitude; ...@@ -13,7 +13,8 @@ let user_longitude;
13 let hospital_list = []; 13 let hospital_list = [];
14 14
15 router.get('/hospital', function (req, res) { 15 router.get('/hospital', function (req, res) {
16 - let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=30&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`; 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 request(pet_url, function(err, response, body){ 18 request(pet_url, function(err, response, body){
18 if(err) { 19 if(err) {
19 console.log(`err => ${err}`) 20 console.log(`err => ${err}`)
...@@ -22,22 +23,24 @@ router.get('/hospital', function (req, res) { ...@@ -22,22 +23,24 @@ router.get('/hospital', function (req, res) {
22 if(res.statusCode == 200) { 23 if(res.statusCode == 200) {
23 var result = convert.xml2json(body, {compact: true, spaces: 4}); 24 var result = convert.xml2json(body, {compact: true, spaces: 4});
24 var petJson = JSON.parse(result) 25 var petJson = JSON.parse(result)
25 - var numRows = petJson.response.body.numOfRows._text;
26 var itemList = petJson.response.body.items; 26 var itemList = petJson.response.body.items;
27 + var numRows = itemList.item.length; //개수
27 for (i=0; i<numRows; i++){ 28 for (i=0; i<numRows; i++){
28 - if (itemList.item[i].state._text == '정상'){ 29 + // state 정상인 것만 추리기
30 + if (itemList.item[i].state._text == '정상'){
29 hospital_list.push(itemList.item[i]); 31 hospital_list.push(itemList.item[i]);
30 } 32 }
31 } 33 }
32 34
35 + //테스트용 console.log
33 var titles = ''; 36 var titles = '';
34 -
35 for(i=0; i<hospital_list.length; i++){ 37 for(i=0; i<hospital_list.length; i++){
36 titles = titles+hospital_list[i].title._text+'\n'; 38 titles = titles+hospital_list[i].title._text+'\n';
37 - } 39 + }
40 + console.log(titles);
38 } 41 }
39 } 42 }
40 - res.send(titles); 43 + res.send("finish");
41 }) 44 })
42 }); 45 });
43 46
......