Created
April 20, 2022 14:48
-
-
Save mikkipastel/a69cfe47a2cf63c84b98b5401a3b17d9 to your computer and use it in GitHub Desktop.
Replies with 10 holiday date!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getHolidayList() { | |
const nowDateTime = (new Date()).toISOString(); | |
return axios.get( | |
getGoogleCalendarApiPath(process.env.CALENDAR_HOLIDAY_IN_BNAGKOK_ID), | |
{ | |
params: { | |
orderBy: 'startTime', | |
singleEvents: true, | |
key: process.env.GOOGLE_API_KEY, | |
timeMin: nowDateTime, | |
maxResults: 10 | |
} | |
} | |
).then(function (response) { | |
console.log(response.data.items); | |
if (response.data.items.length > 0) { | |
var printText = ""; | |
console.log(response.data.items); | |
response.data.items.forEach(function (item, index) { | |
printText += '[ ' + item.start.date + ' ] ' + item.summary; | |
if (index < response.data.items.length - 1) { | |
printText += '\n'; | |
} | |
}); | |
console.log(printText); | |
return printText; | |
} | |
}).catch(function (error) { | |
console.log(error); | |
}); | |
} | |
module.exports = { | |
getHolidayList | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment