전언석

Delete api받을수있는코드.js

// var xhr = new XMLHttpRequest();
// var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/
// var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/
// queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/
// queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/
// queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/
// queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/
// queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/
// xhr.open('GET', url + queryParams);
// xhr.onreadystatechange = function () {
// if (this.readyState == 4) {
// alert('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText);
// }
// };
// xhr.send('');
var XMLHttpRequest = require('xhr2');
var xhr = new XMLHttpRequest();
var url = 'http://apis.data.go.kr/1390802/AgriFood/FdCkry/getKoreanFoodFdCkryList'; /*URL*/
var queryParams = '?' + encodeURIComponent('serviceKey') + '='+'R7bFhjvvAMmxJxzcrL8NWkYHVa227zfpwvpwgXxcixNdMY0EbdbsbCboj3zXEsXniKNHyqu2dEllJCRk1LsdxA%3D%3D'; /*Service Key*/
queryParams += '&' + encodeURIComponent('service_Type') + '=' + encodeURIComponent('xml'); /**/
queryParams += '&' + encodeURIComponent('Page_No') + '=' + encodeURIComponent('1'); /**/
queryParams += '&' + encodeURIComponent('Page_Size') + '=' + encodeURIComponent('20'); /**/
queryParams += '&' + encodeURIComponent('food_Name') + '=' + encodeURIComponent('밥'); /**/
queryParams += '&' + encodeURIComponent('ckry_Name') + '=' + encodeURIComponent('조리'); /**/
xhr.open('GET', url + queryParams);
xhr.onreadystatechange = function () {
if (this.readyState == 4) {
//console.log('Status: '+this.status+'nHeaders: '+JSON.stringify(this.getAllResponseHeaders())+'nBody: '+this.responseText);
//console.log(this.responseText);
console.log(this.responseText);
console.log("hehe\n");
console.log(queryParams);
}
};
xhr.send('');
\ No newline at end of file