discourse/app/assets/javascripts/wizard/lib/ajax.js.es6

19 lines
378 B
Text
Raw Normal View History

2016-08-25 13:14:56 -04:00
let token;
export function ajax(args) {
if (!token) {
token = $('meta[name="csrf-token"]').attr('content');
}
return new Ember.RSVP.Promise((resolve, reject) => {
args.headers = {
'X-CSRF-Token': token
};
args.success = data => Ember.run(null, resolve, data);
args.error = xhr => Ember.run(null, reject, xhr);
Ember.$.ajax(args);
});
}