import Action from './../../packages/runner/actions/action.ts' import State from './../../packages/runner/_state.ts' import ical from 'node-ical' /** * getting ics from url and parse it to object * * @author Björn Hase * @license http://opensource.org/licenses/MIT The MIT License * @link https://git.node001.net/HerrHase/super-hog.git * */ class IcsExample extends Action { async run() { let response try { response = await fetch(this.config.url) } catch(error) { throw new Error(error) } // if code is 200 if (response && response.status === 200) { const body = await response.text() const events = ical.sync.parseICS(body) if (events) { this.result = events } } } } export default IcsExample