0
我想從後端使用ZOHO的郵件使用的的NodeJS的CalDAV日曆溝通使用的CalDav從ZOHO日曆事件。任何人都可以建議我如何實現它? 我使用的插件節點的CalDAV-MOD如何讀取並獲得的node.js
我想這段代碼似乎並不奏效。
var caldav = require("node-caldav-mod");
var moment = require('moment-timezone');
var express = require('express');
var app = express();
var xmljs = require("libxmljs");
var https = require("https");
var CalendarId = "2123123123";
var url = "https://calendar.zoho.com/caldav/{CalendarId}/events";
var username = "username"
var password = "password"
var timeFormat = "YYYYMMDDTHHmms";
var getTodayEvent = function (callback){
var startDate = moment().set({'hour': 0,'minute': 0,'second': 0}).format(timeFormat) + "Z";
var endDate = moment().set({'hour': 23,'minute': 59,'second': 59}).format(timeFormat) + "Z";
var output = {};
output.startDate = startDate;
output.endDate = endDate;
caldav.getEvents(url, username, password, startDate, endDate, function(response){
console.log(response);
callback(response);
});
}
var findPropertyNameByRegex = function(o, r) {
var key;
for (key in o) {
if (key.match(r)) {
return key;
}
}
return undefined;
};
function compare(a,b) {
var startDate_a = findPropertyNameByRegex(a, "DTSTART");
var startDate_b = findPropertyNameByRegex(b, "DTSTART");
if (a[startDate_a] < b[startDate_b])
return -1;
else if (a[startDate_a] > b[startDate_b])
return 1;
else
return 0;
}
app.get('/today',function(req, res){
getTodayEvent(function(events){
events.sort(compare);
res.send("Communication set up properly!")
})
});
這是我得到
Parsing.....
undefined
Error parsing response
TypeError: Cannot read property 'D:multistatus' of undefined
有人能告訴我有什麼不對的代碼中的錯誤?
有人可以建議我解決這個問題嗎?自從最近兩天以來,我一直在爲此而頭痛。任何幫助將非常感激 – Anamika