martyjs / marty

A Javascript library for state management in React applications
http://martyjs.org
MIT License
1.09k stars 76 forks source link

CORS requests with HttpStateSource #125

Closed doesnotexist closed 9 years ago

doesnotexist commented 9 years ago

It is not clear how one would go about sending a CORS request using the HttpStateSource. Has anyone done this? Perhaps there should be an example of such a thing in the docs.

jhollingworth commented 9 years ago

HttpStateSource just uses the fetch API so I think you will be able to do:

var FooStateSource = Marty.createStateSource({
  type: 'http',
  getFoo: function () {
    return this.get({ url: 'http://whatever.com/foos', cors: true })
  }
});