Edits history of script submission #2953 for ' Update a List (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a List
     * Update the properties of a List
     */
    export async function main(
      auth: Trello,
      id: string,
      name: string | undefined,
      closed: string | undefined,
      idBoard: string | undefined,
      pos: string | undefined,
      subscribed: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/lists/${id}`);
      for (const [k, v] of [
        ["name", name],
        ["closed", closed],
        ["idBoard", idBoard],
        ["pos", pos],
        ["subscribed", subscribed],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 399 days ago

  • nativets
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Update a List
     * Update the properties of a List
     */
    export async function main(
      auth: Trello,
      id: string,
      name: string | undefined,
      closed: string | undefined,
      idBoard: string | undefined,
      pos: string | undefined,
      subscribed: string | undefined
    ) {
      const url = new URL(`https://api.trello.com/1/lists/${id}`);
      for (const [k, v] of [
        ["name", name],
        ["closed", closed],
        ["idBoard", idBoard],
        ["pos", pos],
        ["subscribed", subscribed],
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          Authorization: undefined,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 953 days ago