Skip to content

Instantly share code, notes, and snippets.

@r002
Last active August 14, 2021 01:48
Show Gist options
  • Select an option

  • Save r002/68d58b7e2b94924eb5b98cf0900f1fbe to your computer and use it in GitHub Desktop.

Select an option

Save r002/68d58b7e2b94924eb5b98cf0900f1fbe to your computer and use it in GitHub Desktop.
JSON REST API call that doesn't return CORS
// 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