Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Sending the output of an api call to extendscript

Community Beginner ,
Jun 04, 2024 Jun 04, 2024
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:
AnnBens_0-1717502776174.png

 

 
 
 
 

 

TOPICS
SDK
2.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 3 Correct answers

Adobe Employee , Jun 05, 2024 Jun 05, 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.


Translate
Adobe Employee , Jun 08, 2024 Jun 08, 2024

It seems that if you pass a string, not an object, it'll work.

Translate
Adobe Employee , Jun 10, 2024 Jun 10, 2024

> 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.

Translate
Adobe Employee ,
Jun 04, 2024 Jun 04, 2024

What does apiCall() actually return?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 05, 2024 Jun 05, 2024

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

harsh34949843p78e_2-1717574090628.pngharsh34949843p78e_3-1717574101671.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 05, 2024 Jun 05, 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.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 05, 2024 Jun 05, 2024

That's right but if you would look at the third line of the function apiOutput0() I have used the JSON.stringify() on the object. So, I guess that solves the string problem, right?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 05, 2024 Jun 05, 2024

Perhaps; what do your results show? Do you get different results, if you instead pass a hard-coded string?

I referred you to this working example of passing data between JavaScript and ExtendScript; where does your usage, depart from the example?

I'm not clear why you're adding two sets of punctuation around Result, when you pass it to evalScript...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 08, 2024 Jun 08, 2024

When I pass a hard-coded string I get the expected results i.e the string gets alerted as it is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 08, 2024 Jun 08, 2024

It seems that if you pass a string, not an object, it'll work.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 09, 2024 Jun 09, 2024

In that case we have already seen that JSON.stringify doesn't work so how do I send it as a string

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 09, 2024 Jun 09, 2024

I'm not sure what's not working in your panel.

PProPanel contains multiple examples of building up a String containing a function call and programmatically built parameters.

Where does your panel's usage, depart from these?

https://github.com/Adobe-CEP/Samples/blob/9efca02ea88ad32a8c22571f5ffe2407ae732cd8/PProPanel/index.h...

 

https://github.com/Adobe-CEP/Samples/blob/9efca02ea88ad32a8c22571f5ffe2407ae732cd8/PProPanel/index.h...


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 10, 2024 Jun 10, 2024

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 10, 2024 Jun 10, 2024

> 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 10, 2024 Jun 10, 2024

The difficulty I am facing is that JSX is not recognizing 'await'. When I wrapped my code in try/catch statements I found that JSX proceeds further right away without waiting for await function to complete. The code you referenced has no use or inclusion of such functionality.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Jun 10, 2024 Jun 10, 2024
LATEST

That makes complete sense, as ExtendScript is ECMA3, and JavaScript is ECMA6. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines