0
mounted(){
 this.$http.get('http:anotherurl.com/api/data.xml')
.then(function (response) {
    console.log(response);
  });
}

i get this console error :

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

i test vue-resource with reddit and it worked fine but with this url gives the problem . please help .

andrew s zachary
  • 167
  • 2
  • 14
  • See https://stackoverflow.com/questions/20035101/no-access-control-allow-origin-header-is-present-on-the-requested-resource/42744707#42744707 – sideshowbarker Aug 14 '17 at 06:26

3 Answers3

1

The people who set up anotherurl.com have configured it to not allow requests via JavaScript from sites other than their own. This is a feature of HTTP / CORS.

For further reading, the Mozilla documentation explains a little more about what is going on:

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Origin

exclsr
  • 3,329
  • 23
  • 27
  • i even set Access-Control-Allow-Origin : * wildcard but still issue with ajax request , but if i put the url in the browser , the browser will recieve the xml data in a page , do u think it is an issue with the api – andrew s zachary Aug 14 '17 at 08:03
  • 1
    i think u were right ... i told the backend and they told me **the surprise** it is not allow requests via JavaScript using another server ... thx for help – andrew s zachary Aug 14 '17 at 13:21
0

If you are using chrome you can get an extension to ignore xframe-headers. don't know how to solve it in production though

Nadeem Shadan
  • 89
  • 1
  • 6
-1

I would say that as vue-resource is deprecated from 2.0 v you should look at newer API like this one here - https://github.com/mzabriskie/axios

Axios is powerful-promise based HTTP client for the browser and node.js

Meet Zaveri
  • 2,921
  • 1
  • 22
  • 33
  • i tested with axios and jquery but still the same . api like reddit works fine but this api still has issue – andrew s zachary Aug 14 '17 at 08:39
  • 1
    vue-ressource is *not* deprecated, it is merely no longer part of the [official recommendation](https://medium.com/the-vue-point/retiring-vue-resource-871a82880af4). – cello Aug 14 '17 at 09:20
  • yea apology man, ya it is no longer part of vue.js after vue 2.0 in documentation – Meet Zaveri Aug 15 '17 at 07:29