1

I'm having trouble using vue-resource with some json data. I'm following the example here: https://github.com/vuejs/vue-resource/blob/master/docs/http.md

My vue-resource call looks like this:

  ready: function() {    
    this.$http.get('http://section.dynns.com/sections').then(function (response) {
      this.$set('data_list', response.data)
  });
},

See jsfiddle here: http://jsfiddle.net/greene48/yb5chmfr/

But, switching that api call for a different set of data seems to work: http://jsfiddle.net/greene48/92gfwqL3/

So, maybe there is something wrong with the json I'm trying to use? Any help would be appreciated. Thanks

greenerr
  • 119
  • 3
  • 10

1 Answers1

2

http://jsonplaceholder.typicode.com/posts sets CORS headers. http://section.dynns.com/sections does not. Without CORS headers, your requests to a different domain name are subject to the browser's same-origin policy and will fail.

Your other options are JSONP (if the API supports it) or proxying requests through a server-side script.

ceejayoz
  • 176,543
  • 40
  • 303
  • 368
  • 1
    Thanks alot, this might have been an obvious answer but I'm new to all this. I added CORS headers to the data and it seems to be working now. – greenerr Feb 09 '16 at 20:47