Inject session for vanilla ajax requests
This commit is contained in:
parent
bbcef5459e
commit
f06fbd0305
5 changed files with 17 additions and 5 deletions
|
@ -1,9 +1,14 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default function ajaxRequest(url, options) {
|
||||
export default function ajaxRequest(url, options, session) {
|
||||
return new Ember.RSVP.Promise(function(resolve, reject) {
|
||||
options = options || {};
|
||||
options.url = url;
|
||||
session.authorize('authorizer:application', (headerName, headerValue) => {
|
||||
let authHeader = {};
|
||||
authHeader[headerName] = headerValue;
|
||||
options.headers = authHeader;
|
||||
});
|
||||
options.success = function(data) {
|
||||
resolve(data);
|
||||
};
|
||||
|
|
Reference in a new issue