//native
/**
* Get User
* Get a user by gid, email or `me` (the token's own user, the default). The response lists the user's workspaces.
*/
export async function main(
auth: RT.Asana,
user_gid: string | undefined,
opt_fields: string | undefined
) {
const url = new URL(`https://app.asana.com/api/1.0/users/${user_gid || "me"}`)
const params = { opt_fields }
for (const [key, value] of Object.entries(params)) {
if (value != null && value !== "") {
url.searchParams.append(key, String(value))
}
}
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${auth.token}`,
Accept: "application/json",
},
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
return await response.json()
}
Submitted by hugo989 3 hours ago