Last active
August 14, 2021 01:48
-
-
Save r002/68d58b7e2b94924eb5b98cf0900f1fbe to your computer and use it in GitHub Desktop.
JSON REST API call that doesn't return CORS
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
| // Will work in Postman but not in jsfiddle or client-side/browser code! | |
| const url = 'https://ctwc-cloud.appspot.com/v1/match/ctwc_2014_r5-01' | |
| fetch(url).then((response) => { | |
| if (response.ok) { | |
| return response.json() | |
| } else { | |
| throw new Error('Something went wrong') | |
| } | |
| }) | |
| .then((responseJson) => { | |
| console.log(responseJson) | |
| }) | |
| .catch((error) => { | |
| console.log(error) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment