Showing
2 changed files
with
34 additions
and
9 deletions
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | const request = require('request'); | 2 | const request = require('request'); |
3 | -const api_url = 'http://apis.data.go.kr/1471000/FoodAdtvInfoService'; | 3 | +const api_url = 'http://apis.data.go.kr/1471000/FoodAdtvInfoService/getFoodAdtvInfoList?'; |
4 | //발급받은 키 | 4 | //발급받은 키 |
5 | const key = 'PFs%2BxbmfLdZwXaK7l5l9w4xEcdaDcYByiEj9PoHq2KCPAtx%2FE1N7OPUaCPr6bam18nVQgKOnuxMlaRsJhG6gyQ%3D%3D' | 5 | const key = 'PFs%2BxbmfLdZwXaK7l5l9w4xEcdaDcYByiEj9PoHq2KCPAtx%2FE1N7OPUaCPr6bam18nVQgKOnuxMlaRsJhG6gyQ%3D%3D' |
6 | 6 | ||
7 | -const a_url = api_url +'/getFoodAdtvInfoList?ServiceKey='+key+'&numOfRows=3&pageNo=1'; | 7 | +const a_url = api_url +'ServiceKey='+key+'&numOfRows=3&pageNo=4'; |
8 | 8 | ||
9 | console.log(a_url); | 9 | console.log(a_url); |
10 | 10 | ||
11 | + | ||
12 | +request(a_url, function(error, response, body){ | ||
13 | + if(!error && response.statusCode ==200) | ||
14 | + console.log(body); | ||
15 | +}) | ||
16 | + | ||
17 | +/* | ||
11 | request.post({ | 18 | request.post({ |
12 | url: a_url, | 19 | url: a_url, |
13 | form:{ | 20 | form:{ |
... | @@ -16,4 +23,5 @@ request.post({ | ... | @@ -16,4 +23,5 @@ request.post({ |
16 | 23 | ||
17 | },(error,respopnse,body) =>{ | 24 | },(error,respopnse,body) =>{ |
18 | console.log(body) | 25 | console.log(body) |
19 | -}); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
26 | +}); | ||
27 | +*/ | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | let request = require('request'); | 1 | let request = require('request'); |
2 | 2 | ||
3 | // REST API 경로 & 요청 메시지 | 3 | // REST API 경로 & 요청 메시지 |
4 | -const url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList'; | 4 | +const url = 'http://apis.data.go.kr/1470000/FoodAdtvInfoService/getFoodAdtvInfoList?ServiceKey='; |
5 | -const queryParams = '?' + encodeURIComponent('ServiceKey') + '=ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; /* Service Key*/ | 5 | + |
6 | -queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); /* */ | 6 | +//api key |
7 | -queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료'); /* */ | 7 | +const key = 'ofY2ppOq5kBqT5jYPaGsW%2BEy7OR5a1bf5Z9PHvqNKvwO5DSCaU2x2qCj%2FoXnuB1YVbMTlErkHWSMEsR5b7isrw%3D%3D'; |
8 | -queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ | 8 | + |
9 | -queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('3'); /* */ | 9 | +//REST(URL) |
10 | +const complete_url = url +key ;// '&numOfRows=2&pageNo=2'; | ||
11 | + | ||
12 | +console.log(complete_url); | ||
13 | + | ||
14 | +request(complete_url, function(error, response, body){ | ||
15 | + if(!error && response.statusCode ==200) | ||
16 | + console.log(body); | ||
17 | +}) | ||
18 | + | ||
19 | + | ||
20 | +/* | ||
21 | +queryParams += '&' + encodeURIComponent('prdlst_cd') + '=' + encodeURIComponent('C0118010300000'); | ||
22 | +queryParams += '&' + encodeURIComponent('pc_kor_nm') + '=' + encodeURIComponent('과.채음료'); | ||
23 | +queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); | ||
24 | +queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('3'); | ||
25 | +*/ | ||
26 | + | ||
10 | 27 | ||
11 | /* | 28 | /* |
12 | 예제코드 | 29 | 예제코드 | ... | ... |
-
Please register or login to post a comment