Edits history of script submission #3140 for ' Create Reaction for Action (trello)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Trello = {
      key: string;
      token: string;
    };
    /**
     * Create Reaction for Action
     * Adds a new reaction to an action
     */
    export async function main(
      auth: Trello,
      idAction: string,
      body: {
        shortName?: string;
        skinVariation?: string;
        native?: string;
        unified?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.trello.com/1/actions/${idAction}/reactions`);
      for (const [k, v] of [
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: undefined,
        },
        body: JSON.stringify(body),
      });
      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;
    };
    /**
     * Create Reaction for Action
     * Adds a new reaction to an action
     */
    export async function main(
      auth: Trello,
      idAction: string,
      body: {
        shortName?: string;
        skinVariation?: string;
        native?: string;
        unified?: string;
        [k: string]: unknown;
      }
    ) {
      const url = new URL(`https://api.trello.com/1/actions/${idAction}/reactions`);
      for (const [k, v] of [
        ["key", auth.key],
        ["token", auth.token],
      ]) {
        if (v !== undefined && v !== "") {
          url.searchParams.append(k, v);
        }
      }
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: undefined,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.text();
    }
    

    Submitted by hugo697 953 days ago