xm4dn355x

fkn promises

Apr 7th, 2021
417
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script type="text/javascript">
  2.     console.log("test script");
  3.     // let postList;
  4.     // try {
  5.     // postList = fetch('/imonitor/api/v1/post/list').then((response) => {
  6.     //     return response.json();
  7.     // }).then((data) => {return data;});
  8.     // } catch (error) {
  9.     //     console.log('ERROR!!!')
  10.     //     console.log(error);
  11.     // }
  12.     //
  13.     // console.log(postList)
  14.  
  15.     // let postList;
  16.     // fetch('/imonitor/api/v1/post/list')
  17.     //     .then(response => response.ok ? response : Promise.reject(response))
  18.     //     .then(response => response.json())
  19.     //     .then(json => {
  20.     //         // console.log(json);
  21.     //         // console.log(typeof json);
  22.     //         postList = json;
  23.     //         // console.log(typeof postList)
  24.     //         // console.log(postList)
  25.     //     });
  26.     // console.log(postList);
  27.    
  28.     async function getPostList() {
  29.         const response = await fetch('/imonitor/api/v1/post/list')
  30.             .then(response => response.ok ? response : Promise.reject(response))
  31.         const resArr = await response.json();
  32.         return resArr;
  33.     };
  34.  
  35.     let postList = getPostList()
  36.     console.log(postList)
  37.  
  38. </script>
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×