오수빈

modify numRow

......@@ -13,7 +13,8 @@ let user_longitude;
let hospital_list = [];
router.get('/hospital', function (req, res) {
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`;
//api
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`;
request(pet_url, function(err, response, body){
if(err) {
console.log(`err => ${err}`)
......@@ -22,22 +23,24 @@ router.get('/hospital', function (req, res) {
if(res.statusCode == 200) {
var result = convert.xml2json(body, {compact: true, spaces: 4});
var petJson = JSON.parse(result)
var numRows = petJson.response.body.numOfRows._text;
var itemList = petJson.response.body.items;
var numRows = itemList.item.length; //개수
for (i=0; i<numRows; i++){
if (itemList.item[i].state._text == '정상'){
// state 정상인 것만 추리기
if (itemList.item[i].state._text == '정상'){
hospital_list.push(itemList.item[i]);
}
}
//테스트용 console.log
var titles = '';
for(i=0; i<hospital_list.length; i++){
titles = titles+hospital_list[i].title._text+'\n';
}
}
console.log(titles);
}
}
res.send(titles);
res.send("finish");
})
});
......