//native
type Miro = {
token: string;
};
/**
* Create mind map node
* Adds a mind map node to a board.
*/
export async function main(
auth: Miro,
board_id: string,
body: {
data: { nodeView: { data?: { type: string; content?: string } } };
position?: { x?: number; y?: number };
geometry?: { width?: number };
parent?: { id?: string };
},
) {
const url = new URL(
`https://api.miro.com//v2-experimental/boards/${board_id}/mindmap_nodes`,
);
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