-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.js
More file actions
29 lines (25 loc) · 973 Bytes
/
Copy pathcreate.js
File metadata and controls
29 lines (25 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { CWBlocks } from './lib/cwblocks.js';
try {
/**
* Set up the CW Blocks instance and authenticate with environment variables
* @see {@link https://github.com/wfurphy/bynder-content-blocks}
*/
const cb = new CWBlocks(
process.env.EMAIL, //::> Email address
process.env.API_KEY //::> API Key
);
/**
* Create new item with the matching fields populated from Content Blocks
* CONFIG variables can be replaced with unique values here. Repeat for each item.
* @see {@link CWBlocks.createItem}
* @see {@link CWBlocks.CONFIG}
*/
const output = await cb.createItem(
cb.getUniqueItemName(), //::> Item Name
CWBlocks.CONFIG.TEMPLATES.PRODUCT, //::> Template ID
CWBlocks.CONFIG.GROUPS.PRODUCT_ONE, //::> Master Template Group Name (Optional)
);
console.log('::BynderContentBlocks::| Item Created |::>', output);
} catch (error) {
console.error('::BynderContentBlocks::| ERROR |::>', error);
}