mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
18 lines
378 B
JavaScript
18 lines
378 B
JavaScript
|
|
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);
|
|
});
|
|
}
|