-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclickup.js
More file actions
39 lines (35 loc) · 1.19 KB
/
clickup.js
File metadata and controls
39 lines (35 loc) · 1.19 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
const { Clickup } = require('clickup.js');
const clickupToken = process.env.CLICKUP_TOKEN; // API access token
const clickup = new Clickup(clickupToken);
const createTask = async (taskNmae, taskDescription, listId=205795695) => {
try {
// create a task on a list
const taskData = {
name: taskNmae,
description: taskDescription,
tags: ['Support'],
status: 'To Do',
notify_all: true,
parent: null,
links_to: null,
};
const { body } = await clickup.lists.createTask(listId, taskData);
console.log(body);
} catch (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.body);
console.log(error.response.statusCode);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.log(error.options);
}
};
exports.createTask = createTask