곽태식

error

1 const db = require('./db.js'); 1 const db = require('./db.js');
2 const secret_key = require('../keys/api_option').key; 2 const secret_key = require('../keys/api_option').key;
3 -const secret_D_key = require('../keys/api_option').D_key;//사망교통사고 키 3 +//const secret_D_key = require('../keys/api_option').D_key;//사망교통사고 키
4 const requesting = require('request'); 4 const requesting = require('request');
5 const lat = "37.239795"; 5 const lat = "37.239795";
6 const lon = "127.083240"; 6 const lon = "127.083240";
...@@ -49,27 +49,7 @@ module.exports = (server, app) => { ...@@ -49,27 +49,7 @@ module.exports = (server, app) => {
49 }) 49 })
50 } 50 }
51 51
52 - const req_D_API = () =>{ 52 +
53 -
54 - return new Promise((resolve, reject) => {
55 - requesting.get({
56 - // api를 요청할 주소 -- 시크릿키 입력, 경기도 수원시 설정
57 - url: `http://taas.koroad.or.kr/data/rest/accident/death?authKey=${secret_D_key}searchYear=2018&sido=1300&guGun=1302&type=json`,
58 - json: true
59 - },
60 - //api에게 응답 받았을때 실행되는 callback function
61 - function (err, api_res, api_body) {
62 - //err 존재시 promise reject 호출
63 - if (err) reject(err);
64 -
65 - // api의 response이 있을경우 promise resolve 호출
66 - if (api_res) {
67 - console.log("calling api");
68 - resolve(api_body);
69 - }
70 - });
71 - })
72 - }
73 53
74 54
75 const API_bundle = async () => { 55 const API_bundle = async () => {
...@@ -80,7 +60,7 @@ module.exports = (server, app) => { ...@@ -80,7 +60,7 @@ module.exports = (server, app) => {
80 Heat_index = await req_API("index", "heat"); //열지수 60 Heat_index = await req_API("index", "heat"); //열지수
81 Discomport_index = await req_API("index", "th"); //불쾌지수 61 Discomport_index = await req_API("index", "th"); //불쾌지수
82 Ultra_Violet_index = await req_API("index", "uv"); //자외선지수 62 Ultra_Violet_index = await req_API("index", "uv"); //자외선지수
83 - let kts = await req_D_API(); 63 + //let kts = await req_D_API();
84 64
85 info = { 65 info = {
86 heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수 66 heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수
...@@ -95,7 +75,7 @@ module.exports = (server, app) => { ...@@ -95,7 +75,7 @@ module.exports = (server, app) => {
95 warning: Current_Weather.common.alertYn, //현재 특보 유무 75 warning: Current_Weather.common.alertYn, //현재 특보 유무
96 typhoon: Current_Weather.common.stormYn, //현재 태풍 76 typhoon: Current_Weather.common.stormYn, //현재 태풍
97 time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각 77 time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각
98 - death_prob: 0, //확률 78 + death_prob: 0 //확률
99 79
100 } 80 }
101 console.log("API INFO \n", info); 81 console.log("API INFO \n", info);
......