collection.getAllVariables()
collection.getAllVariables()
Get all variables in a collection
Syntax
collection.getAllVariables(): Promise<Array<Variable>>
Returns
Promise<Variable>
A Promise that resolves to an array of Variable objects
Example
// Fetch the default variable collection
const defaultVariableCollection = await webflow.getDefaultVariableCollection();
if (defaultVariableCollection) {
// Print Collection ID
console.log("Default Variable Collection ID:", defaultVariableCollection.id);
// Fetch all variables within the default collection
const variables = await defaultVariableCollection.getAllVariables();
if (variables.length > 0) {
console.log("List of Variables in Default Collection:");
// Print variable details
for (var i in variables) {
console.log(`${i}. Variable Name: ${await variables[i].getName()}, Variable ID: ${variables[i].id}`);
};
} else {
console.log("No variables found in the default collection.");
}
} else {
console.log("Default Variable Collection not found.");
Designer Ability
Checks for Authorization only
Designer Ability | Locale | Branch | Workflow | Sitemode |
---|---|---|---|---|
canReadVariables | Any | Any | Any | Any |