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

Fetch() inside CEP

Explorer ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

Hi; I have a Q re fetch() insed 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!

 

 

 

function doWorkForComp(nextLayerToBeProcessed){

    var output1 = document.querySelector('.output1');
    var output2 = document.querySelector('.output2');  
     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
User interface or workspaces

Views

264

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
community guidelines
LEGEND ,
Jul 06, 2020 Jul 06, 2020

Copy link to clipboard

Copied

fetch() is based on a browser API, not a JS standard function. Naturally it may not work everywhere.

 

Mylenium

Votes

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
community guidelines
Explorer ,
Jul 08, 2020 Jul 08, 2020

Copy link to clipboard

Copied

LATEST

It's a CEP panel so that would be Chrome and Fetch() is certainly supported by Chrome at my version. 

Votes

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
community guidelines