Skip to content

Instantly share code, notes, and snippets.

@boy-jer
Forked from seifsallam/RESTAdapter.js
Created June 23, 2013 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boy-jer/5845345 to your computer and use it in GitHub Desktop.
Save boy-jer/5845345 to your computer and use it in GitHub Desktop.
// store.js
App.Adapter = DS.RESTAdapter.reopen({
bulkCommit: false,
url: 'http://localhost:5000',
namespace: 'api',
corsWithCredentials: true,
headers: {
'Accept': 'application/vnd.vendor+json;version=1',
'Content-type': 'application/json',
'x-vendor-appid': '123',
'x-vendor-secret': '12345'
},
ajax: function(url, type, hash) {
if (this.headers !== undefined) {
var headers = this.headers;
if (hash) {
hash.beforeSend = function (xhr) {
Ember.keys(headers).forEach(function(key) {
xhr.setRequestHeader(key, headers[key]);
});
};
}
}
return this._super(url, type, hash);
}
});
// Add maping and extra configuration here before you create the object
App.Store = DS.Store.extend({
adapter: App.Adapter.create()
});
App.store = App.Store.create();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment