//native
type Clickup = {
token: string;
};
/**
* Create Key Result
* Add a Target to a Goal.
*/
export async function main(
auth: Clickup,
goal_id: string,
body: {
name: string;
owners: number[];
type: string;
steps_start: number;
steps_end: number;
unit: string;
task_ids: string[];
list_ids: string[];
},
) {
const url = new URL(
`https://api.clickup.com/api/v2/goal/${goal_id}/key_result`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 168 days ago