Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_fetchData() {
const start = dates.firstVisibleDay(this.currentDate).toISOString();
const end = dates.lastVisibleDay(this.currentDate).toISOString();
const params = encodeURI(`?start=${start}&end=${end}`);
const calls = this.selectedCalendars.map((cal) =>
this.hass.callApi("get", `calendars/${cal}${params}`)
);
Promise.all(calls).then((results) => {
const tmpEvents = [];
results.forEach((res) => {
res.forEach((ev) => {
ev.start = new Date(ev.start);
if (ev.end) {
ev.end = new Date(ev.end);
} else {
ev.end = null;
}