You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
890 B

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 <me@herr-hase.wtf>
* @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