Skip to main content
Question

getVariableByIdAsync got error when the variable (color) is not used in the file

  • February 12, 2025
  • 2 replies
  • 33 views

Toshiyuki_Hayashi

Hello,

I’m using getVariableByIdAsync API to get a variable info. For example, I try to load a color variable which key is VariableID:d2c9451722738c45a0c75047e467b459856cce94/49352:54

The code will be:

const iconTertiaryVariable = await figma.variables.getVariableByIdAsync(

"VariableID:d2c9451722738c83a0c75047e467b459865cce94/49352:173"

);
If I use the color variable in the figma file already in another element, it works. But If I haven’t used the variable yet in the file, I got error always. It says:
The variable with id "xxxxxxxx" does not exist.
How I can load the variable without this error?

Thanks,

Toshi

2 replies

tank666
  • 4873 replies
  • February 13, 2025

Toshiyuki_Hayashi

@tank666 Thank you!! That’s exactly I was looking for. You made my day. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings