shin0112

modify emergency_api.js

1 -const { query } = require('express');
2 const express = require('express'); 1 const express = require('express');
3 const app = express(); 2 const app = express();
4 const request = require('request'); 3 const request = require('request');
5 const convert = require("xml-js"); 4 const convert = require("xml-js");
6 5
7 -var url = 'http://apis.data.go.kr/B552657/ErmctInfoInqireService/getEmrrmRltmUsefulSckbdInfoInqire'; 6 +var url = 'http://apis.data.go.kr/B552657/ErmctInfoInqireService/getSrsillDissAceptncPosblInfoInqire';
8 var queryParams = '?' + encodeURIComponent('serviceKey') + '=52tXHgaW46YUpGn9k0r3IQrduIl6kBOl3Ta8Idra1%2BpPMYhL4qVCDu9itW8FVbDtMF4f9LAT9NJXEx7pvEJv%2FQ%3D%3D'; /* Service Key*/ 7 var queryParams = '?' + encodeURIComponent('serviceKey') + '=52tXHgaW46YUpGn9k0r3IQrduIl6kBOl3Ta8Idra1%2BpPMYhL4qVCDu9itW8FVbDtMF4f9LAT9NJXEx7pvEJv%2FQ%3D%3D'; /* Service Key*/
9 8
10 -queryParams += '&' + encodeURIComponent('STAGE1') + '=' + '%EC%84%9C%EC%9A%B8%ED%8A%B9%EB%B3%84%EC%8B%9C'; /* */ 9 +queryParams += '&' + encodeURIComponent('STAGE1') + '=' + '%EC%84%9C%EC%9A%B8%ED%8A%B9%EB%B3%84%EC%8B%9C'; /* encodeURIComponent('¼­¿ïƯº°½Ã')*/
11 queryParams += '&' + encodeURIComponent('STAGE2') + '=' + '%EA%B0%95%EB%82%A8%EA%B5%AC'; /* */ 10 queryParams += '&' + encodeURIComponent('STAGE2') + '=' + '%EA%B0%95%EB%82%A8%EA%B5%AC'; /* */
12 queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */ 11 queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent('1'); /* */
13 queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */ 12 queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent('10'); /* */
14 13
15 -console.log(url+queryParams);
16 -
17 request({ 14 request({
18 url: url + queryParams, 15 url: url + queryParams,
19 method: 'GET' 16 method: 'GET'
...@@ -23,10 +20,8 @@ request({ ...@@ -23,10 +20,8 @@ request({
23 } 20 }
24 else{ 21 else{
25 var result = body 22 var result = body
26 - console.log(`body data => ${result}`) 23 + var xmlTojson = convert.xml2json(result, {compact: true, spaces:1});
27 - var xmlTojson = convert.xml2json(result, {compact: true, spaces:4}); 24 + console.log(xmlTojson)
28 - console.log(`xml to json => ${xmlTojson}`)
29 } 25 }
30 -
31 } 26 }
32 ); 27 );
...\ No newline at end of file ...\ No newline at end of file
......