Skip to main content
Chaitanya_Rajguru
August 19, 2024
Solved

How to make async call to the figma.getNodeByIdAsync() function?

  • August 19, 2024
  • 11 replies
  • 464 views

Greetings from a newbie!

I cannot get a call to Figma.getNodeByIdAsync() to work. Could anyone please tell me what I am doing wrong? I have searched this forum and referred to a sample plugin go-to that uses this function, but I am still stuck.

Below is my simplified code just for checking this functionality. When I run it as part of the plugin, console logs #1 and #2 are generated but not #3, and the console returns to the ‘>’ prompt.

Thank you!

Figma_plugin_issue

This topic has been closed for replies.
Best answer by Pavel_Kiselev

To make it work you need to run it async way. Just wrap your code into another asynchronous function and run getParent with await keyword

(async ()=> {
    //…
    await getParen(id);
    figma.closePlugin();
})()

11 replies

Chaitanya_Rajguru
August 22, 2024

Update: The last code I shared in this post is working today! 👍 I am not sure what changed since yesterday other than a couple of restarts of Figma and VSC, but no complaints. Thanks a lot for your help @tank666 and @Pavel_Kiselev !