Last active
August 15, 2016 19:37
-
-
Save seifsallam/5845028 to your computer and use it in GitHub Desktop.
Ember RESTAdapter configuration for sending HTTP header and CrossDomain Access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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