Advertisement
Guest User

Untitled

a guest
Apr 4th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. <script>
  2. const URL = ;
  3. async function makeAPIcall(){
  4. const result = await fetch(URL, { mode: 'no-cors'})
  5. result.json().then(data =>{console.log(data)})
  6. }
  7. async function makeAPIcall2(){
  8. fetch(
  9. URL, {
  10. method: "GET", // *GET, POST, PUT, DELETE, etc.
  11. mode: "no-cors", // no-cors, *cors, same-origin
  12. cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
  13. credentials: "same-origin", // include, *same-origin, omit
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. // 'Content-Type': 'application/x-www-form-urlencoded',
  17. },
  18. redirect: "follow", // manual, *follow, error
  19. referrerPolicy: "no-referrer", // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
  20. body: JSON.stringify(response => response.json())
  21. })
  22. .then((response) => response.json())
  23. .then((response) => {
  24. console.log(response);
  25. })
  26. .then((data) => {
  27. console.log(data);
  28. })
  29. }
  30. makeAPIcall2();
  31. makeAPIcall();
  32. </script>
  33. </head>
  34.  
  35. <body>
  36. </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement