Toggle navigation
Toggle navigation
This project
Loading...
Sign in
term-project
/
project
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
박주영
2020-12-03 01:01:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
773c66acd9fd03938bf46885c5d5b76ca9b318d8
773c66ac
1 parent
a48612d8
조금 수정
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
express/foodapi.js
express/foodapi.js
View file @
773c66a
...
...
@@ -8,9 +8,9 @@ var url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoLis
var
key
=
'ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'
;
var
queryParams
=
'?'
+
encodeURIComponent
(
'ServiceKey'
)
+
'='
+
key
;
//queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000');
queryParams
+=
'&'
+
encodeURIComponent
(
'pc_kor_nm'
)
+
'='
+
encodeURIComponent
(
'스위트초콜릿'
);
//queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('
3');
//
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('100');
queryParams
+=
'&'
+
encodeURIComponent
(
'pc_kor_nm'
)
;
//
+ '=' + encodeURIComponent('스위트초콜릿');
queryParams
+=
'&'
+
encodeURIComponent
(
'pageNo'
)
+
'='
+
encodeURIComponent
(
'21
3'
);
queryParams
+=
'&'
+
encodeURIComponent
(
'numOfRows'
)
+
'='
+
encodeURIComponent
(
'100'
);
global
.
foods
=
new
Array
();
...
...
@@ -29,17 +29,20 @@ request({
//console.log(xmltojson);
var
resObj
=
eval
(
"("
+
xmltojson
+
")"
);
var
resultItems
=
resObj
.
response
.
body
.
items
;
console
.
log
(
xmltojson
);
var
responseMessage
=
'[ '
+
resultItems
.
item
[
0
].
PC_KOR_NM
.
_text
+
' ]\n'
;
//
console.log(xmltojson);
for
(
var
i
=
0
;
i
<
resultItems
.
item
.
length
;
i
++
){
var
responseMessage
=
'[ '
+
resultItems
.
item
[
i
].
PC_KOR_NM
.
_text
+
' ]\n'
;
var
addictive
=
resultItems
.
item
[
i
].
T_KOR_NM
.
_text
;
var
specVal
=
resultItems
.
item
[
i
].
SPEC_VAL_SUMUP
.
_text
;
responseMessage
+=
addictive
+
' : '
+
specVal
+
'\n'
;
}
var
yn
=
resultItems
.
item
[
i
].
INJRY_YN
.
_text
;
responseMessage
+=
addictive
+
' : '
+
specVal
+
'['
+
yn
+
']'
+
'\n'
;
console
.
log
(
'[responese message]'
,
responseMessage
);
}
}
}
//console.log('Status', response.statusCode);
//console.log('Headers', JSON.stringify(response.headers));
...
...
Please
register
or
login
to post a comment