Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- console.log("test script");
- // let postList;
- // try {
- // postList = fetch('/imonitor/api/v1/post/list').then((response) => {
- // return response.json();
- // }).then((data) => {return data;});
- // } catch (error) {
- // console.log('ERROR!!!')
- // console.log(error);
- // }
- //
- // console.log(postList)
- // let postList;
- // fetch('/imonitor/api/v1/post/list')
- // .then(response => response.ok ? response : Promise.reject(response))
- // .then(response => response.json())
- // .then(json => {
- // // console.log(json);
- // // console.log(typeof json);
- // postList = json;
- // // console.log(typeof postList)
- // // console.log(postList)
- // });
- // console.log(postList);
- async function getPostList() {
- const response = await fetch('/imonitor/api/v1/post/list')
- .then(response => response.ok ? response : Promise.reject(response))
- const resArr = await response.json();
- return resArr;
- };
- let postList = getPostList()
- console.log(postList)
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement