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

0

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.