type Asana = {
token: string;
};
/**
* Remove a custom field from a project
* Removes a custom field setting from a project.
*/
export async function main(
auth: Asana,
project_gid: string,
opt_pretty: string | undefined,
body: {
data?: { custom_field: string; [k: string]: unknown };
[k: string]: unknown;
}
) {
const url = new URL(
`https://app.asana.com/api/1.0/projects/${project_gid}/removeCustomFieldSetting`
);
for (const [k, v] of [["opt_pretty", opt_pretty]]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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 449 days ago