Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- const URL = ;
- async function makeAPIcall(){
- const result = await fetch(URL, { mode: 'no-cors'})
- result.json().then(data =>{console.log(data)})
- }
- async function makeAPIcall2(){
- fetch(
- URL, {
- method: "GET", // *GET, POST, PUT, DELETE, etc.
- mode: "no-cors", // no-cors, *cors, same-origin
- cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
- credentials: "same-origin", // include, *same-origin, omit
- headers: {
- 'Content-Type': 'application/json',
- // 'Content-Type': 'application/x-www-form-urlencoded',
- },
- redirect: "follow", // manual, *follow, error
- 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
- body: JSON.stringify(response => response.json())
- })
- .then((response) => response.json())
- .then((response) => {
- console.log(response);
- })
- .then((data) => {
- console.log(data);
- })
- }
- makeAPIcall2();
- makeAPIcall();
- </script>
- </head>
- <body>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement