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-11-28 01:33:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d7a0fbb599b601af25791446c1c996e92233520f
d7a0fbb5
1 parent
6f27098a
m
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
9 deletions
express/app2.js
express/foodapi.js
express/app2.js
View file @
d7a0fbb
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
api_url
=
'http://apis.data.go.kr/1471000/FoodAdtvInfoService'
;
const
api_url
=
'http://apis.data.go.kr/1471000/FoodAdtvInfoService
/getFoodAdtvInfoList?
'
;
//발급받은 키
const
key
=
'PFs%2BxbmfLdZwXaK7l5l9w4xEcdaDcYByiEj9PoHq2KCPAtx%2FE1N7OPUaCPr6bam18nVQgKOnuxMlaRsJhG6gyQ%3D%3D'
const
a_url
=
api_url
+
'
/getFoodAdtvInfoList?ServiceKey='
+
key
+
'&numOfRows=3&pageNo=1
'
;
const
a_url
=
api_url
+
'
ServiceKey='
+
key
+
'&numOfRows=3&pageNo=4
'
;
console
.
log
(
a_url
);
request
(
a_url
,
function
(
error
,
response
,
body
){
if
(
!
error
&&
response
.
statusCode
==
200
)
console
.
log
(
body
);
})
/*
request.post({
url: a_url,
form:{
...
...
@@ -16,4 +23,5 @@ request.post({
},(error,respopnse,body) =>{
console.log(body)
});
\ No newline at end of file
});
*/
\ No newline at end of file
...
...
express/foodapi.js
View file @
d7a0fbb
let
request
=
require
(
'request'
);
// REST API 경로 & 요청 메시지
const
url
=
'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList'
;
const
queryParams
=
'?'
+
encodeURIComponent
(
'ServiceKey'
)
+
'=ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'
;
/* Service Key*/
queryParams
+=
'&'
+
encodeURIComponent
(
'prdlst_cd'
)
+
'='
+
encodeURIComponent
(
'C0118010300000'
);
/* */
queryParams
+=
'&'
+
encodeURIComponent
(
'pc_kor_nm'
)
+
'='
+
encodeURIComponent
(
'과.채음료'
);
/* */
queryParams
+=
'&'
+
encodeURIComponent
(
'pageNo'
)
+
'='
+
encodeURIComponent
(
'1'
);
/* */
queryParams
+=
'&'
+
encodeURIComponent
(
'numOfRows'
)
+
'='
+
encodeURIComponent
(
'3'
);
/* */
const
url
=
'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList?ServiceKey='
;
//api key
const
key
=
'ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'
;
//REST(URL)
const
complete_url
=
url
+
key
;
// '&numOfRows=2&pageNo=2';
console
.
log
(
complete_url
);
request
(
complete_url
,
function
(
error
,
response
,
body
){
if
(
!
error
&&
response
.
statusCode
==
200
)
console
.
log
(
body
);
})
/*
queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000');
queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료');
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1');
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('3');
*/
/*
예제코드
...
...
Please
register
or
login
to post a comment