Created
April 23, 2020 10:40
-
-
Save l0co/5826ba79e1e02f9a2f1f1c50516664d7 to your computer and use it in GitHub Desktop.
Simple script to test if CORS works from the browser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| for (let method of ['GET', 'POST']) { | |
| fetch('http://example.com', {method}).then(e => { | |
| document.write('<p>' + method + ' succeded with result: ' + e + '</p>') | |
| console.log(e) | |
| }).catch(e => { | |
| document.write('<p>' + method + ' failed due to: ' + e + '</p>') | |
| }); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment