calendar.js
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var express = require('express');
var router = express.Router();
var gcal = require('google-calendar');
router.post('/calendar',function(req,res,next){
var id = req.body.id;
res.render('calendar',{id: id});
});
//router.get('/',function(req,res,next){
//var accessToken = req.session.access_token;
//gcal(accessToken).calendarList.list(function(err,data){
//if(err) return res.send(err);
//return res.render('calendar',{calendars : data});
//});
//res.render('calendar',{id:1});
console.log(1);
//})
calList = new Array();
router.get('/', function(req, res, next) {
if(!req.session.googleToken) return res.redirect('/auth/google');
else
googleToken = req.session.googleToken;
kakaoToken = req.session.kakaoToken;
gcal(googleToken).calendarList.list(function(err,data){
if(err) return console.log(err);
else {
calList = data.items;
//console.log(calList);
res.render('calendar',{calList:calList,googleToken:googleToken,kakaoToken:kakaoToken});
}
});
});
module.exports = router;
//db에서 calendar id에 해당하는 이벤트 출력