//native
type Clickup = {
token: string;
};
/**
* Search Docs
* View the Docs in your Workspace. You can only view information of Docs you can access.
*/
export async function main(
auth: Clickup,
workspaceId: string,
id: string | undefined,
creator: string | undefined,
deleted: string | undefined,
archived: string | undefined,
parent_id: string | undefined,
parent_type: string | undefined,
limit: string | undefined,
next_cursor: string | undefined,
) {
const url = new URL(
`https://api.clickup.com/api/v3/workspaces/${workspaceId}/docs`,
);
for (const [k, v] of [
["id", id],
["creator", creator],
["deleted", deleted],
["archived", archived],
["parent_id", parent_id],
["parent_type", parent_type],
["limit", limit],
["next_cursor", next_cursor],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: 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 235 days ago