collection.getAllVariables()

Get all variables in a collection

Syntax

1collection.getAllVariables(): Promise<Array<Variable>>

Returns

Promise<Variable>

A Promise that resolves to an array of Variable objects

Example

1// Fetch the default variable collection
2const defaultVariableCollection = await webflow.getDefaultVariableCollection();
3
4if (defaultVariableCollection) {
5
6 // Print Collection ID
7 console.log("Default Variable Collection ID:", defaultVariableCollection.id);
8
9 // Fetch all variables within the default collection
10 const variables = await defaultVariableCollection.getAllVariables();
11
12 if (variables.length > 0) {
13
14 console.log("List of Variables in Default Collection:");
15
16 // Print variable details
17 for (var i in variables) {
18 console.log(`${i}. Variable Name: ${await variables[i].getName()}, Variable ID: ${variables[i].id}`);
19 };
20 } else {
21 console.log("No variables found in the default collection.");
22 }
23} else {
24 console.log("Default Variable Collection not found.");

Designer Ability

Checks for Authorization only

Designer AbilityLocaleBranchWorkflowSitemode
canReadVariablesAnyAnyAnyAny