Edits history of script submission #3174 for ' Get a project's custom fields (asana)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Asana = {
      token: string;
    };
    /**
     * Get a project's custom fields
     * Returns a list of all of the custom fields settings on a project, in compact form. Note that, as in all queries to collections which return compact representation, `opt_fields` can be used to include more data than is returned in the compact representation. See the [getting started guide on input/output options](https://developers.asana.com/docs/#input-output-options) for more information.
     */
    export async function main(
      auth: Asana,
      project_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      limit: string | undefined,
      offset: string | undefined
    ) {
      const url = new URL(
        `https://app.asana.com/api/1.0/projects/${project_gid}/custom_field_settings`
      );
      for (const [k, v] of [
        ["opt_pretty", opt_pretty],
        ["opt_fields", opt_fields],
        ["limit", limit],
        ["offset", offset],
      ]) {
        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

  • nativets
    type Asana = {
      token: string;
    };
    /**
     * Get a project's custom fields
     * Returns a list of all of the custom fields settings on a project, in compact form. Note that, as in all queries to collections which return compact representation, `opt_fields` can be used to include more data than is returned in the compact representation. See the [getting started guide on input/output options](https://developers.asana.com/docs/#input-output-options) for more information.
     */
    export async function main(
      auth: Asana,
      project_gid: string,
      opt_pretty: string | undefined,
      opt_fields: string | undefined,
      limit: string | undefined,
      offset: string | undefined
    ) {
      const url = new URL(
        `https://app.asana.com/api/1.0/projects/${project_gid}/custom_field_settings`
      );
      for (const [k, v] of [
        ["opt_pretty", opt_pretty],
        ["opt_fields", opt_fields],
        ["limit", limit],
        ["offset", offset],
      ]) {
        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