Advertisement
loggerer

get dem JSONs

Aug 16th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var myRequest = new Request('hidden from nohusuro')
  2. var myInit = {
  3.     method: 'GET',
  4.     mode: 'cors',
  5.     cache: 'default'
  6. };
  7.  
  8. async function getData() {
  9.     const response = await fetch(myRequest, myInit);
  10.     return await response.json();
  11. }
  12.  
  13. window.onload = function () {
  14.     getData().then(batch => {
  15.         buildPage(batch);
  16.     })
  17. }
  18.  
  19. function buildPage(batch) {
  20.     const parsedJSON = batch.map(e => JSON.parse(e.data))
  21.     container.append.apply(container, parsedJSON.map(value => {
  22.         var obj = document.createElement('div');
  23.         obj.textContent = value.item[0].name;
  24.         return obj;
  25.     }));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement