Edits history of script submission #17409 for ' Update tag (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Update tag
     * Updates a tag based on the data properties provided in the request body.
     */
    export async function main(
      auth: Miro,
      board_id: string,
      tag_id: string,
      body: {
        fillColor?:
          | "red"
          | "light_green"
          | "cyan"
          | "yellow"
          | "magenta"
          | "green"
          | "blue"
          | "gray"
          | "violet"
          | "dark_green"
          | "dark_blue"
          | "black";
        title?: string;
      },
    ) {
      const url = new URL(
        `https://api.miro.com//v2/boards/${board_id}/tags/${tag_id}`,
      );
    
      const response = await fetch(url, {
        method: "PATCH",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.token,
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago