type Asana = {
token: string;
};
/**
* Get objects via typeahead
* Retrieves objects in the workspace based via an auto-completion/typeahead
search algorithm.
*/
export async function main(
auth: Asana,
workspace_gid: string,
resource_type:
| "custom_field"
| "project"
| "project_template"
| "portfolio"
| "tag"
| "task"
| "user"
| undefined,
type:
| "custom_field"
| "portfolio"
| "project"
| "tag"
| "task"
| "user"
| undefined,
query: string | undefined,
count: string | undefined,
opt_pretty: string | undefined,
opt_fields: string | undefined
) {
const url = new URL(
`https://app.asana.com/api/1.0/workspaces/${workspace_gid}/typeahead`
);
for (const [k, v] of [
["resource_type", resource_type],
["type", type],
["query", query],
["count", count],
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
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 383 days ago
type Asana = {
token: string;
};
/**
* Get objects via typeahead
* Retrieves objects in the workspace based via an auto-completion/typeahead
search algorithm.
*/
export async function main(
auth: Asana,
workspace_gid: string,
resource_type:
| "custom_field"
| "project"
| "project_template"
| "portfolio"
| "tag"
| "task"
| "user"
| undefined,
type:
| "custom_field"
| "portfolio"
| "project"
| "tag"
| "task"
| "user"
| undefined,
query: string | undefined,
count: string | undefined,
opt_pretty: string | undefined,
opt_fields: string | undefined
) {
const url = new URL(
`https://app.asana.com/api/1.0/workspaces/${workspace_gid}/typeahead`
);
for (const [k, v] of [
["resource_type", resource_type],
["type", type],
["query", query],
["count", count],
["opt_pretty", opt_pretty],
["opt_fields", opt_fields],
]) {
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 937 days ago