Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source-group1
/
animal-Info
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
오수빈
2021-05-29 23:48:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
dff8d6bfe0575c63fcab884304f6a3e7bd125938
dff8d6bf
1 parent
7098960a
add function list_print
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
13 deletions
routes/category.js
routes/category.js
View file @
dff8d6b
...
...
@@ -13,19 +13,9 @@ let user_latitude;
let
user_longitude
;
let
hospital_list
=
[];
router
.
post
(
'/hospital'
,
function
(
req
,
res
){
//gu 받아오기
var
body
=
req
.
body
;
var
gu_select
=
body
.
user_gu
;
//console.log(gu_select);
// encoding for url
var
menu
=
urlencode
(
'동물병원'
);
var
gu_select_encode
=
urlencode
(
gu_select
);
//console.log(gu_select_encode);
function
list_print
(
res
,
menu_encode
,
gu_select_encode
){
//api
let
pet_url
=
`http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=
${
ANIMAL_INFO_API_KEY
}
&numOfRows=100&pageNo=1&keyword=
${
menu
}
&where=
${
gu_select_encode
}
`
;
let
pet_url
=
`http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=
${
ANIMAL_INFO_API_KEY
}
&numOfRows=100&pageNo=1&keyword=
${
menu
_encode
}
&where=
${
gu_select_encode
}
`
;
request
(
pet_url
,
function
(
err
,
response
,
body
){
if
(
err
)
{
console
.
log
(
`err =>
${
err
}
`
)
...
...
@@ -52,7 +42,50 @@ router.post('/hospital', function(req, res){
}
}
res
.
render
(
'result'
,
{
category
:
'hospital'
,
titles
:
titles
,
hospital_list
:
hospital_list
});
})
});
}
router
.
post
(
'/hospital'
,
function
(
req
,
res
){
//gu 받아오기
var
body
=
req
.
body
;
var
gu_select
=
body
.
user_gu
;
var
menu
=
'동물병원'
;
// encoding for url
var
menu_encode
=
urlencode
(
menu
);
var
gu_select_encode
=
urlencode
(
gu_select
);
list_print
(
res
,
menu_encode
,
gu_select_encode
);
// //api
// let pet_url = `http://api.kcisa.kr/openapi/service/rest/convergence2019/getConver03?serviceKey=${ANIMAL_INFO_API_KEY}&numOfRows=100&pageNo=1&keyword=${menu_encode}&where=${gu_select_encode}`;
// request(pet_url, function(err, response, body){
// if(err) {
// console.log(`err => ${err}`)
// }
// else {
// if(res.statusCode == 200) {
// var result = convert.xml2json(body, {compact: true, spaces: 4});
// var petJson = JSON.parse(result)
// var itemList = petJson.response.body.items;
// var numRows = itemList.item.length; //개수
// for (i=0; i<numRows; i++){
// // 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.render('result', { category: 'hospital', titles: titles, hospital_list: hospital_list });
// })
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment