박지환

Update get this month data

Showing 1 changed file with 17 additions and 4 deletions
......@@ -13,13 +13,11 @@ var operation = "getHoliDeInfo";
// Do not modify the values
var SERVEICE_KEY =
"qBtJy2Prw8CCnAiijUM7VkuaA9MZozHuiQI4FbEGYdUDPz4%2FM%2FuxegGjNBWK0aWQHvSslVHwIZQwNWh57WgRTA%3D%3D";
var url =
"http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/" +
operation;
var url = "http://apis.data.go.kr/B090041/openapi/service/SpcdeInfoService/";
var queryParams = "?" + "solYear" + "=" + year;
queryParams += "&" + "solMonth" + "=" + month;
queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY;
let requestUrl = url + queryParams;
let requestUrl = url + operation + queryParams;
// Empty variables
var text = "";
......@@ -65,8 +63,23 @@ function getDate(dateName, locdate) {
return dday;
}
function changeParams(year, month, operation) {
queryParams = "?" + "solYear" + "=" + year;
queryParams += "&" + "solMonth" + "=" + month;
queryParams += "&" + "ServiceKey" + "=" + SERVEICE_KEY;
requestUrl = url + operation + queryParams;
}
// To initialize datas when calling webpage
function init() {
// Intialize Year, Month
var date = getTodayDate().split("-");
year = date[0];
month = date[1];
operation = "getHoliDeInfo";
console.log(year, month);
changeParams(year, month, operation);
// Get data from holiday api
request.get(requestUrl, (err, res, body) => {
if (err) {
console.log("err => " + err);
......