Skip to content

Instantly share code, notes, and snippets.

@mikkipastel
Created April 20, 2022 14:48
Show Gist options
  • Save mikkipastel/a69cfe47a2cf63c84b98b5401a3b17d9 to your computer and use it in GitHub Desktop.
Save mikkipastel/a69cfe47a2cf63c84b98b5401a3b17d9 to your computer and use it in GitHub Desktop.
Replies with 10 holiday date!
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