Public
Script
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { TanaAPIHelper } from "https://esm.town/v/nbbaier/TanaAPIHelper";
import { tanaConstants } from "https://esm.town/v/nbbaier/tanaConstants";
import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
/** saveToTana - creates a node in Tana via the Tana Input API
* @param {string} token - Token for accessing the API.
* @param {APIPlainNode} node - Data node to be created in Tana.
* @param {string} targetNodeId - ID of the target node where the new node will be attached (defaults to the inbox)
* @returns {Promise<APIPlainNode>} - A promise that resolves to the created node.
*/
export const saveToTana = async (
token: string,
node: APIPlainNode,
targetNodeId: string = tanaConstants.inboxNodeId,
) => {
const client = new TanaAPIHelper(token);
const createdNode = await client.createNode(node, targetNodeId);
return createdNode;
};
October 27, 2023