jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.3k stars 513 forks source link

Error: Invalid frequency: weekly weekly #439

Open abi2810 opened 3 years ago

abi2810 commented 3 years ago

I'm trying to get the rrule from request.body, here is the sample way of rrule Im passing.

{ 
    "rrule": {
                  "freq": "weekly",
                  "interval": 5,
                 "byweekday": [ "sat","sun" ],
                 "dtstart": "2020-10-28T11:00:00",
                 "until": "2020-10-29T11:30:00"
               }
}

And My Code, Im trying to set new rule by passing the constructed rrule from request.body.

function newEvent(req: Request, res: Response) {
     let rruleJson = req.body.rrule;
    const rule = new RRule(rruleJson);
    let getRule = rule.all()
    res.send(getRule)
 }

And Im getting this error,

UnhandledPromiseRejectionWarning: Error: Invalid frequency: weekly weekly
    at parseOptions (/node_modules/rrule/dist/es5/webpack:/rrule/src/parseoptions.ts:31:11)
    at new RRule (/node_modules/rrule/dist/es5/webpack:/rrule/src/rrule.ts:112:13)
    at next (/node_modules/express/lib/router/index.js:275:10)

Can anyone help me on this to resolve it.

masterpandabear commented 3 years ago

The freq property must be a (number) constant, you can read about it in the API description in the documentation, the library provides enums for them.