Can you use an XMLHttpRequest
to access an API such as the police API or the World Bank API? If so, how does the site circumvent Same-Origin Policy?
Asked
Active
Viewed 25 times
0

Beta Decay
- 805
- 1
- 8
- 20
-
@Alexander Possible, but this isn't about any site, just APIs – Beta Decay Jul 13 '16 at 18:42
-
2Same-Origin Policy does not recognize a difference. – Alexander O'Mara Jul 13 '16 at 18:43
-
@Alexander So, no, I cannot access these APIs with JavaScript? – Beta Decay Jul 13 '16 at 18:47
-
1Exactly, the restrictions are the same, regardless of the URL. – Haroldo_OK Jul 13 '16 at 18:47
-
Have you even tried making a request to any of these APIs in JavaScript? `fetch('https://data.police.uk/api/crimes-street-dates')` seems to work without any issues. – fny Jul 13 '16 at 18:52
-
@faraz Well, not yet. I was trying to see whether it is worth writing a program to use an API tomorrow – Beta Decay Jul 13 '16 at 19:02
-
Your question is entirely moot since there's no CORS issue to begin with... – fny Jul 13 '16 at 19:04