Building a CalDAV client with web components

Some steps and pitfalls on my way creating a CalDAV client with webcomponents
1. If you want to use moment.js include it this way
import moment from ‚moment‘; window.moment = moment; 
2. The template for the „REPORT“ request should look like this, e.g. to get the events for a time range. Mind, there MUST NOT BE any whitespace between the backtick and the start of the xml declaration.
const query = (start,end) => `                                             `;
3. I had to start Chrome like this to get rid of CORS issues
open -a Google Chrome –args –disable-web-security –user-data-dir=„“
4. The fetch request should look like this
  let start = moment().subtract(5,’days‘);         let end = moment();         let startString =  start.format(„YYYYMMDD[T]000000[Z]“);         let endString = end.format(„YYYYMMDD[T]000000[Z]“);         let myHeaders = new Headers();         myHeaders.append(„DEPTH“,“1″);         myHeaders.append(„Authorization“,“Basic “ + authentication);
        console.log(‚caldaving‘, startString,endString)
        fetch(url,{             method: „REPORT“,             headers : myHeaders,             body : query(startString,endString)         })         .then(response => {             console.log(„reso“, response)             let xml = response.text();             console.log(‚Got appointments‘, xml);             return xml;         }).then(xml => console.log(‚xml‘,xml))
5. To get the authentication as base64 use „ echo -n user:password | base64“ Mind the „-n“ otherwise you get a line break at the end!

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.