UNPKG

abdeltuto

Version:

Shows holidays by entering the country name and year

23 lines (22 loc) 575 B
#!/usr/bin/env node let country, year,countrycode; country=process.argv[2]; year=process.argv[3]; if(!year) { year = new Date().getFullYear(); } const { getCode, getName } = require('country-list'); countrycode= getCode(country); const axios = require('axios'); axios.get(`https://date.nager.at/api/v2/publicholidays/${year}/${countrycode}`) .then(function (response) { // handle success response.data.forEach(dates => { console.log(dates.date+" " +dates.name); }); }) .catch(function (error) { // handle error console.log(error); });