type Asana = {
token: string;
};
/**
* Get goal relationships
* Returns compact goal relationship records.
*/
export async function main(
auth: Asana,
opt_pretty: string | undefined,
opt_fields: string | undefined,
supported_goal: string | undefined,
resource_subtype: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/goal_relationships`);
for (const [k, v] of [
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
["supported_goal", supported_goal],
["resource_subtype", resource_subtype],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 418 days ago