Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Wait for an async operation to complete before updating the UI with output.text

Solved
Jump to Solution
967 2
cancel
Showing results for 
Search instead for 
Did you mean: 
craibuc
6 - Interface Innovator
6 - Interface Innovator

I added a button to a table that forms a task when the button is clicked.

The task is an async call to a REST API using Javascript's fetch.  I'd like to be able to display the state of the operation, including when its completed.

The code:

// make the REST API with an async function
const response = await updateLicense(config.access_token, employeeNumber, licenseNumber);

// dispay the results of the processing
output.text(response)

 Unfortunately, the code doesn't wait for the updateLicense function to complete.  Any ideas?

1 Solution

Accepted Solutions
craibuc
6 - Interface Innovator
6 - Interface Innovator

The script works correctly, but I forgot that the webhook is async, so it returns a unique identifier early, rather than the full results when it completed.

See Solution in Thread

2 Replies 2
kuovonne
18 - Pluto
18 - Pluto

What does the rest of the script look like, including the updateLicense() function? Is it an async function where you await the fetch?

craibuc
6 - Interface Innovator
6 - Interface Innovator

The script works correctly, but I forgot that the webhook is async, so it returns a unique identifier early, rather than the full results when it completed.