박지환

Update get this month data

Showing 1 changed file with 17 additions and 4 deletions
...@@ -13,13 +13,11 @@ var operation = "getHoliDeInfo"; ...@@ -13,13 +13,11 @@ var operation = "getHoliDeInfo";
13 // Do not modify the values 13 // Do not modify the values
14 var SERVEICE_KEY = 14 var SERVEICE_KEY =
15 "qBtJy2Prw8CCnAiijUM7VkuaA9MZozHuiQI4FbEGYdUDPz4%2FM%2FuxegGjNBWK0aWQHvSslVHwIZQwNWh57WgRTA%3D%3D"; 15 "qBtJy2Prw8CCnAiijUM7VkuaA9MZozHuiQI4FbEGYdUDPz4%2FM%2FuxegGjNBWK0aWQHvSslVHwIZQwNWh57WgRTA%3D%3D";
16 -var url = 16 +var url = "http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/";
17 - "http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/" +
18 - operation;
19 var queryParams = "?" + "solYear" + "=" + year; 17 var queryParams = "?" + "solYear" + "=" + year;
20 queryParams += "&" + "solMonth" + "=" + month; 18 queryParams += "&" + "solMonth" + "=" + month;
21 queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY; 19 queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY;
22 -let requestUrl = url + queryParams; 20 +let requestUrl = url + operation + queryParams;
23 21
24 // Empty variables 22 // Empty variables
25 var text = ""; 23 var text = "";
...@@ -65,8 +63,23 @@ function getDate(dateName, locdate) { ...@@ -65,8 +63,23 @@ function getDate(dateName, locdate) {
65 return dday; 63 return dday;
66 } 64 }
67 65
66 +function changeParams(year, month, operation) {
67 + queryParams = "?" + "solYear" + "=" + year;
68 + queryParams += "&" + "solMonth" + "=" + month;
69 + queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY;
70 + requestUrl = url + operation + queryParams;
71 +}
72 +
68 // To initialize datas when calling webpage 73 // To initialize datas when calling webpage
69 function init() { 74 function init() {
75 + // Intialize Year, Month
76 + var date = getTodayDate().split("-");
77 + year = date[0];
78 + month = date[1];
79 + operation = "getHoliDeInfo";
80 + console.log(year, month);
81 + changeParams(year, month, operation);
82 + // Get data from holiday api
70 request.get(requestUrl, (err, res, body) => { 83 request.get(requestUrl, (err, res, body) => {
71 if (err) { 84 if (err) {
72 console.log("err => " + err); 85 console.log("err => " + err);
......