Edits history of script submission #17287 for ' Create card item (miro)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Miro = {
      token: string;
    };
    /**
     * Create card item
     * Adds a card item to a boardRequired scope boards:write Rate limiting Level 2
     */
    export async function main(
      auth: Miro,
      board_id: string,
      body: {
        data?: {
          assigneeId?: string;
          description?: string;
          dueDate?: string;
          title?: string;
        };
        style?: { cardTheme?: string };
        position?: { x?: number; y?: number };
        geometry?: { height?: number; rotation?: number; width?: number };
        parent?: { id?: string };
      },
    ) {
      const url = new URL(`https://api.miro.com//v2/boards/${board_id}/cards`);
    
      const response = await fetch(url, {
        method: "POST",
        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