Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Get data from list of URL's in asynchronous.
- function asyncRequester(url) {
- return fetch(url).then((response) => response.json());
- }
- var urls = ['temp.json', 'temp.json', 'temp.json', 'temp.json', 'temp.json'],
- pall = [],
- resu = document.querySelector('#results');
- for(var i in urls) {
- pall.push(asyncRequester(urls[i]));
- }
- Promise.all(pall).then(function(results) {
- for(var i in results) {
- var li = document.createElement('li'),
- text = document.createTextNode(results[i][0]['title']['rendered']);
- li.appendChild(text);
- resu.appendChild(li);
- }
- });
Add Comment
Please, Sign In to add comment