Search code examples
javascriptweb-serviceschromiumenyo

How to use Enyo 2.0 WebService object


I am building a Campfire client that will run in WebOS and as a Chrome desktop web app. I have the following code:

logIn: function(){
    this.apiToken = this.$.loginScreen.$.apiToken.getValue();
    this.subdomain = this.$.loginScreen.$.subdomain.getValue();
    this.fullURL = 'https://' + this.subdomain + '.campfirenow.com/';
    this.$.roomService.url = this.fullURL + 'rooms.json';
    var response = this.$.roomService.send({'Authorization': "Bearer " + this.apiToken, 'Access-Control-Allow-Origin': this.subdomain + '.campfirenow.com'});

The 'roomService' is like this:

{name: "roomService", kind: "enyo.WebService", url: null, onResponse: "successfulAlert", onError: "someFailure"}

And in Chromium I keep getting the following XMLHttpRequest error:

Origin null is not allowed by Access-Control-Allow-Origin.

Any ideas?


Solution

  • You might want to take a look at this StackOverflow question:

    XmlHttpRequest error: Origin null is not allowed by Access-Control-Allow-Origin

    You're being blocked by trying to run this from a file:// URL.