Showing
1 changed file
with
0 additions
and
38 deletions
api받을수있는코드.js
deleted
100644 → 0
1 | -// var xhr = new XMLHttpRequest(); | ||
2 | -// var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/ | ||
3 | -// var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/ | ||
4 | -// queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/ | ||
5 | -// queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/ | ||
6 | -// queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/ | ||
7 | -// queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/ | ||
8 | -// queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/ | ||
9 | -// xhr.open('GET', url + queryParams); | ||
10 | -// xhr.onreadystatechange = function () { | ||
11 | -// if (this.readyState == 4) { | ||
12 | -// alert('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText); | ||
13 | -// } | ||
14 | -// }; | ||
15 | - | ||
16 | -// xhr.send(''); | ||
17 | - | ||
18 | -var XMLHttpRequest = require('xhr2'); | ||
19 | -var xhr = new XMLHttpRequest(); | ||
20 | -var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/ | ||
21 | -var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/ | ||
22 | -queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/ | ||
23 | -queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/ | ||
24 | -queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/ | ||
25 | -queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/ | ||
26 | -queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/ | ||
27 | -xhr.open('GET', url + queryParams); | ||
28 | -xhr.onreadystatechange = function () { | ||
29 | - if (this.readyState == 4) { | ||
30 | - //console.log('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText); | ||
31 | - //console.log(this.responseText); | ||
32 | - console.log(this.responseText); | ||
33 | - console.log("hehe\n"); | ||
34 | - console.log(queryParams); | ||
35 | - } | ||
36 | -}; | ||
37 | - | ||
38 | -xhr.send(''); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment