-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
41 lines (36 loc) · 803 Bytes
/
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
const { create } = require('axios');
class ClickUp {
constructor(token, {
baseURL = 'https://api.clickup.com/api/v1',
debug = false
} = {}) {
this.client = create({
baseURL,
headers: {
'Authorization': token,
'Content-Type': 'application/json'
}
})
if (debug) {
this.client.interceptors.request.use(request => {
console.log(request);
return request;
});
}
}
async me() {
const { data: { user } } = await this.client.get('/user')
return user;
}
async newTask(listId, task) {
try {
const { data } = await this.client.post(`/list/${listId}/task`, {
...task
})
return data
} catch (error) {
console.log(error.message)
}
}
}
module.exports = ClickUp;