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
Solhee
2020-12-05 02:04:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8ff61b2e619f089805c8295e14d61ffe4612760a
8ff61b2e
1 parent
9ba9f76d
getRawMaterialAndCategoryByProductName
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
express/foodapi_rawmaterial.js
express/foodapi_rawmaterial.js
View file @
8ff61b2
...
...
@@ -3,24 +3,28 @@
var
express
=
require
(
'express'
);
var
request
=
require
(
'request'
);
var
url
=
'http://openapi.foodsafetykorea.go.kr/api'
;
var
key
=
'
인증키'
;
// 12월03일 신청하였습니다.
var
filetype
=
'json'
;
var
url
=
'http://openapi.foodsafetykorea.go.kr/api'
;
var
key
=
'
f8ce3271a2dc4decb83b'
;
var
filetype
=
'json'
;
var
startIndex
=
1
;
var
endIndex
=
5
;
var
NameOfProduct
=
'해오름다시마간장
'
;
// 제품명 넣는 자리
var
NameOfProduct
=
'하루견과 요거트S
'
;
// 제품명 넣는 자리
var
queryParams
=
'/'
+
key
;
var
queryParams
=
'/'
+
encodeURIComponent
(
key
)
;
queryParams
+=
'/'
+
encodeURIComponent
(
'C002'
);
queryParams
+=
'/'
+
encodeURIComponent
(
filetype
);
queryParams
+=
'/'
+
encodeURIComponent
(
'startIdx'
)
+
'='
+
encodeURIComponent
(
startIndex
);
queryParams
+=
'/'
+
encodeURIComponent
(
'endIdx'
)
+
'='
+
encodeURIComponent
(
endIndex
);
queryParams
+=
'
&'
+
encodeURIComponent
(
'PRDLST_NM'
)
+
'='
+
encodeURIComponent
(
'제품명'
);
queryParams
+=
'/'
+
encodeURIComponent
(
startIndex
);
queryParams
+=
'/'
+
encodeURIComponent
(
endIndex
);
queryParams
+=
'
/'
+
encodeURIComponent
(
'PRDLST_NM'
)
+
'='
+
encodeURIComponent
(
NameOfProduct
);
//var fullRequest = encodeURIComponent("http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/xml/1/5/PRDLST_REPORT_NO=200101260032");
//var fullRequest ='http://openapi.foodsafetykorea.go.kr/api/f8ce3271a2dc4decb83b/C002/json/1/5';
console
.
log
(
"[Input msg] "
,
NameOfProduct
);
request
({
url
:
url
+
queryParams
,
//url : fullRequest,
method
:
'GET'
},
function
(
error
,
response
,
body
)
{
if
(
error
){
...
...
@@ -28,13 +32,16 @@ request({
}
else
{
if
(
response
.
statusCode
==
200
){
console
.
log
(
"식품명으로 식품유형과 첨가물 정보를 받아옵니다..."
);
var
result
=
body
;
var
resObj
=
eval
(
"("
+
result
+
")"
);
var
ProductCategory
=
resObj
.
C002
.
row
[
0
].
PRDLST_DCNM
;
// 첨가물정보 API가 입력으로 받을 parameter
console
.
log
(
result
);
//console.log(result);
console
.
log
(
"[처리결과] "
,
resObj
.
C002
.
RESULT
.
MSG
);
console
.
log
(
"[유형] "
,
ProductCategory
);
console
.
log
(
"[첨가물] "
,
resObj
.
C002
.
row
[
0
].
RAWMTRL_NM
)
}
}
...
...
Please
register
or
login
to post a comment