Create a project in a folder
1
//native
2
type Taskade = {
3
token: string
4
}
5
6
export async function main(
7
auth: Taskade,
8
body: { folderId: string; contentType: 'text/markdown'; content: string }
9
) {
10
const url = new URL(`https://www.taskade.com/api/v1/projects`)
11
12
const response = await fetch(url, {
13
method: 'POST',
14
headers: {
15
'Content-Type': 'application/json',
16
Authorization: 'Bearer ' + auth.token
17
},
18
body: JSON.stringify(body)
19
})
20
21
if (!response.ok) {
22
const text = await response.text()
23
throw new Error(`${response.status} ${text}`)
24
25
26
return await response.json()
27
28