Help with variables api and Webflow extension app

Im having problems getting access to variables.

const collection = webflow.getDefaultVariableCollection();

This part above is giving me problems. Maybe I don’t understand it correctly, but when I look in the node modules under Webflow, there is no definition for getDefaultVariableCollection. Am I missing something? It seems like I have it right from the docs ( [Variables & Collections](https://Doc link)).

Here is a larger code section for reference.

// Get default variable collection from Webflow
        const collection = webflow.getDefaultVariableCollection();

        // Iterate through each row of CSV data
        for (const row of parsedData.data) {
            // For simplicity, we'll consider only light mode values here
            const variableName = row['Variable Name'];
            const lightModeValue = row['Light Mode Value'];

            // Check if variable already exists
            let variable = await collection.getVariableByName(variableName);
            if (variable) {
                // If variable exists, update its value
                await variable.set(lightModeValue);
            } else {
                // If variable doesn't exist, create new variable
                // Assuming all variables in the CSV are color variables
                await collection.createColorVariable(variableName, lightModeValue);
            }
        }
    } catch (error) {
        console.error(error);
        displayError(`Processing Error: ${error.message}`);
    }
} 

Hey @Javin_Towers!

Can you try await the collection? i.e.

const collection = await webflow.getDefaultVariableCollection();

Let me know how that goes!

1 Like

Thanks for the help! I added it but i think its more about the type definition. its not defined in the webflow modules.

im pretty sure i have my tsconfig setup properly:

{
  "compilerOptions": {
    "target": "es6",
    "lib": ["es6"],
    "noEmit": true,
    "strict": true,
    "typeRoots": [
      "./node_modules/@types",
    "./node_modules/@webflow"],
  }
}

any thoughts on that?