Highlighted

fetch() in CEP Panel - can't get it to work

New Here ,
Jul 12, 2020

Copy link to clipboard

Copied

Hi All;

Anyone have an idea what the issue is here with a fetch() inside a CEP:

 

The Fetch() code works fine in a standalone JS, but when part of a CEP, it does not - for me. The code executes all the way to "// Get Here" in the code below. Is Fetch() not an option in CEP or what did I screw up? 

 

"doWorkForComp() "is called from a button event   

Thanks so much for any help.

function doWorkForComp(nextLayerToBeProcessed){
     var url = 'https://randomuser.me/api/?results=10'; // Get 10 random users
   
    fetchData();
   
   } 
   
   
    function fetchData() {
      // Get here
      fetch(url)
      .then(function(response){
          return response.json();})
      .then(function(data){     
       data.results.forEach(function (person) {
         alert(person.email);
        })
    });
}

 

TOPICS
How to, Scripting

Views

70

Likes

Translate

Translate

Report

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

fetch() in CEP Panel - can't get it to work

New Here ,
Jul 12, 2020

Copy link to clipboard

Copied

Hi All;

Anyone have an idea what the issue is here with a fetch() inside a CEP:

 

The Fetch() code works fine in a standalone JS, but when part of a CEP, it does not - for me. The code executes all the way to "// Get Here" in the code below. Is Fetch() not an option in CEP or what did I screw up? 

 

"doWorkForComp() "is called from a button event   

Thanks so much for any help.

function doWorkForComp(nextLayerToBeProcessed){
     var url = 'https://randomuser.me/api/?results=10'; // Get 10 random users
   
    fetchData();
   
   } 
   
   
    function fetchData() {
      // Get here
      fetch(url)
      .then(function(response){
          return response.json();})
      .then(function(data){     
       data.results.forEach(function (person) {
         alert(person.email);
        })
    });
}

 

TOPICS
How to, Scripting

Views

71

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 12, 2020 0
Adobe Community Professional ,
Jul 15, 2020

Copy link to clipboard

Copied

Fetch works for me, what version of AE are you using? I'd guess it only works in CC 2018 and up. Try to console.log() your response and see what the issue is.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 15, 2020 0
New Here ,
Jul 20, 2020

Copy link to clipboard

Copied

Thanks for taking the time to respond  Justin; I'm using AE2019. I'll try your suggestion; I've since switched to use "window.cep.fs.readFile()", but would still like to at least understand why "fetch()" doesn't work for me. I'm new to this, so need to know 🙂 

 

Cheers,

Roland

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0
Adobe Community Professional ,
Jul 20, 2020

Copy link to clipboard

Copied

What do you get if you console.log(fetch)? Also, can you post your manifest.xml ?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0
Adobe Community Professional ,
Jul 20, 2020

Copy link to clipboard

Copied

Also, you might need to disable or change the settings in your firewall.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2020 0