Skip to content

Commit

Permalink
simplify getHTMLCalendar function
Browse files Browse the repository at this point in the history
  • Loading branch information
kresnasatya committed Jul 19, 2023
1 parent 78e1e36 commit da2b71d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions services/scraper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { JSDOM } from 'jsdom';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const getHTMLCalendar = (month, year) => {
return new Promise((resolve, reject) => {
fetch(`https://kalenderbali.com?bl=${month}&th=${year}`)
.then(response => resolve(response.text()))
.catch(error => reject(error));
});
const getHTMLCalendar = async (month, year) => {
const response = await fetch(`https://kalenderbali.com?bl=${month}&th=${year}`);
if (!response.ok) {
throw new Error(`An error has occured: ${response.status}`);
}
const text = await response.text();
return text;
}

function zeroPad(num) {
Expand Down

0 comments on commit da2b71d

Please sign in to comment.