-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
53 lines (44 loc) · 1.15 KB
/
index.js
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
42
43
44
45
46
47
48
49
50
const axiosBase = require('axios');
const calendarId = 'replace';
const token = 'replace';
const axios = axiosBase.create({
baseURL: 'https://timetreeapis.com/',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/vnd.timetree.v1+json',
'Authorization': `Bearer ${token}`
},
responseType: 'json'
});
const createEvent = () => {
const params = {
data: {
attributes: {
category: 'schedule',
title: 'これはテストです',
all_day: true,
start_at: '2020-05-04T00:00:00.000Z',
start_timezone: 'UTC',
end_at: `2020-05-04T00:00:00.000Z`,
end_timezone: 'UTC',
description: 'これはテストです',
},
relationships: {
label: {
data: {
id: `${calendarId},7`,
type: "label"
}
}
}
}
};
axios.post(`calendars/${calendarId}/events`, JSON.stringify(params))
.then(response => console.log(response))
}
const getCalendar = () => {
axios.get(`calendars/${calendarId}?include=labels,members`)
.then(response => console.log(response))
}
getCalendar();
createEvent();