Skip to main content
Participating Frequently
June 4, 2024
Answered

Sending the output of an api call to extendscript

  • June 4, 2024
  • 1 reply
  • 3277 views
Hi! I am trying to write a Premiere Pro script in which I make an api call in js and I need to send the output to jsx. But when I alert that received output in jsx it always returns 'undefined'. Another thing that it alerts the output as undefined right away on Premiere Pro but the api call takes about 10 sec to generate the output so in this way it would never alert the desired output. So I also tried to delay the response by using setTimeOut but that didn't work either. Here's my code:

 

 
 
 
 

 

This topic has been closed for replies.
Correct answer Bruce Bullis

Hey I have made some progress and the ouput being an object is not causing issue anymore. 

But still the premiere pro is not able to receive the output of the api call.

In the attached screenshot you can see that there are 2 functions. The first function makes the api call and flattens the output to a string. And the second function sends data to premeire. But when it is called premiere shows not output. So, I put some alerts to check what was working and what wasn't.  So when this function is called only the first alert works and then it doesn't respond or return any alert after that which probably means that the line "const result = await apiOutput0();" is never executed. That line works fine when checked in the js using console.log but while sending to jsx nothing gets executed after that line. 

(Also the api call takes a few seconds to generate the output so I put the setTimeOut there but idk if that serves any objective or not)


> But still the premiere pro is not able to receive the output of the api call.

I have no idea why your JavaScript code fails to work.

The example code I've referenced above, works.

Please base your development on the working examples provided.

1 reply

Bruce Bullis
Community Manager
Community Manager
June 4, 2024

What does apiCall() actually return?

Participating Frequently
June 5, 2024

apiCall returns an object. Here's the code if it helps and the updated code I am using

 

Bruce Bullis
Community Manager
Community Manager
June 5, 2024

>apiCall returns an object.

Then that can never work.

Anything you pass across the ExtendScript <--> JavaScript boundary has to be a simple, contiguous String.