Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to clear all objects from a specific calendar? #146

Open
mikenussbaumer opened this issue Oct 9, 2019 · 0 comments
Open

Comments

@mikenussbaumer
Copy link

Hey!

Is there a way to reset / clear a calendar?

I tried to run this code:

const dav = require('dav');

var xhr = new dav.transport.Basic(
    new dav.Credentials({
        username: '****USER****',
        password: '****PASSWORD****'
    })
);

var client = new dav.Client(xhr);

client.createAccount({
    server: '****SERVER URL****',
    accountType: 'caldav',
    loadObjects: true
}).then((account) => {
    const calendar = account.calendars[0];

    // get all events from calendar
    calendar.objects.forEach((calendarObject) => {
        // remove current event from calendar
        client.deleteCalendarObject(calendarObject, {
            xhr: xhr
        });
    });
});

to remove all objects of a calendar, but unfortunately it does not work properly, im always getting this error:

(node:7783) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 335)
(node:7783) UnhandledPromiseRejectionWarning: Error: Bad status: 412

Maybe anyone here can help me :)

Thanks, Mike

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant