0

I am trying to retrieve data from the following link: https://npropendata.rdw.nl/parkingdata/v2/

Opening the link you will notice that it is in a form of a JSON file. I confirm that the data is correct as I copied the data and saved as a .json file locally and was able to use the $http request to retrieve the data.

Now, how do I retrieve this automatically without having to save the file every time manually, as there is no .json extension in the link? Basically I tried:

app.controller('MyCtrl', function($scope,$http){
   $scope.entries = [];
   $http.get('https://npropendata.rdw.nl/parkingdata/v2/').success(function(data) {

   // do something

   });

});

But that does not work. Copying the data and saving it as a json file and referring it as follows does work:

app.controller('MyCtrl', function($scope,$http){
   $scope.entries = [];
   $http.get('savedfilename.json').success(function(data) {

   // do something

   });

});
WJA
  • 6,676
  • 16
  • 85
  • 152
  • 1
    The problem is Cross Origion Resource Sharing except your web application is hosted at https://npropendata.rdw.nl not about angular. Take a look at the question [How to resolve CORS ie same origin policy in angularjs](http://stackoverflow.com/questions/24446797/how-to-resolve-cors-ie-same-origin-policy-in-angularjs) – shawnzhu Dec 01 '14 at 14:33
  • rdw.nl is an external website, not my application. Any thoughts on that? – WJA Dec 02 '14 at 07:23

1 Answers1

0

You have to add following headers to your api service to enable CORS.

Access-Control-Allow-Origin: [the same origin from the request]
Access-Control-Allow-Methods: GET, POST, PUT
Access-Control-Allow-Headers: [the same ACCESS-CONTROL-REQUEST-HEADERS from request]
khanmizan
  • 926
  • 9
  • 17
  • Where exactly do I need to add those? The dataset is an external website I dont have control on... – WJA Dec 02 '14 at 07:22