This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/utils/ajax-request.js

20 lines
593 B
JavaScript

import Ember from 'ember';
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);
};
options.error = function(jqXHR, status, error) {
reject(jqXHR, status, error);
};
Ember.$.ajax(options);
});
}