1 | |
2 | type Taskade = { |
3 | token: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Taskade, |
8 | projectId: string, |
9 | taskId: string, |
10 | body: { handles: string[] } |
11 | ) { |
12 | const url = new URL( |
13 | `https://www.taskade.com/api/v1/projects/${projectId}/tasks/${taskId}/assignees` |
14 | ) |
15 |
|
16 | const response = await fetch(url, { |
17 | method: 'PUT', |
18 | headers: { |
19 | 'Content-Type': 'application/json', |
20 | Authorization: 'Bearer ' + auth.token |
21 | }, |
22 | body: JSON.stringify(body) |
23 | }) |
24 |
|
25 | if (!response.ok) { |
26 | const text = await response.text() |
27 | throw new Error(`${response.status} ${text}`) |
28 | } |
29 |
|
30 | return await response.json() |
31 | } |
32 |
|