Guest User

Untitled

a guest
Aug 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. // Get data from list of URL's in asynchronous.
  2.  
  3. function asyncRequester(url) {
  4. return fetch(url).then((response) => response.json());
  5. }
  6.  
  7. var urls = ['temp.json', 'temp.json', 'temp.json', 'temp.json', 'temp.json'],
  8. pall = [],
  9. resu = document.querySelector('#results');
  10.  
  11. for(var i in urls) {
  12. pall.push(asyncRequester(urls[i]));
  13. }
  14.  
  15. Promise.all(pall).then(function(results) {
  16. for(var i in results) {
  17. var li = document.createElement('li'),
  18. text = document.createTextNode(results[i][0]['title']['rendered']);
  19. li.appendChild(text);
  20. resu.appendChild(li);
  21. }
  22. });
Add Comment
Please, Sign In to add comment