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-25 07:02:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b36f616d4aae478c942ec7a26e366c8446dff515
b36f616d
1 parent
00d74f86
make array of hospital
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
7 deletions
routes/category.js
routes/category.js
View file @
b36f616
...
...
@@ -10,24 +10,34 @@ let ANIMAL_INFO_API_KEY = process.env.REACT_APP_API_KEY;
let
user_gu
;
let
user_latitude
;
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=10&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
}
`
)
}
else
{
if
(
res
.
statusCode
==
200
)
{
var
result
=
body
;
console
.
log
(
`body data =>
${
result
}
`
);
var
xmlToJson
=
convert
.
xml2json
(
result
,
{
compact
:
true
,
spaces
:
4
});
console
.
log
(
`xml to json =>
${
xmlToJson
}
`
);
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
;
for
(
i
=
0
;
i
<
numRows
;
i
++
){
if
(
itemList
.
item
[
i
].
state
.
_text
==
'정상'
){
hospital_list
.
push
(
itemList
.
item
[
i
]);
}
}
var
titles
=
''
;
for
(
i
=
0
;
i
<
hospital_list
.
length
;
i
++
){
titles
=
titles
+
hospital_list
[
i
].
title
.
_text
+
'\n'
;
}
}
}
res
.
send
(
"finish"
);
res
.
send
(
titles
);
})
});
...
...
Please
register
or
login
to post a comment