main
HerrHase 6 months ago
parent c9c23b7ff7
commit 814bd42b65

@ -0,0 +1,36 @@
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
Loading…
Cancel
Save