mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-17 19:12:37 -05:00
19 lines
420 B
JavaScript
19 lines
420 B
JavaScript
|
|
let token;
|
|
|
|
export function getToken() {
|
|
if (!token) {
|
|
token = $('meta[name="csrf-token"]').attr('content');
|
|
}
|
|
|
|
return token;
|
|
}
|
|
|
|
export function ajax(args) {
|
|
return new Ember.RSVP.Promise((resolve, reject) => {
|
|
args.headers = { 'X-CSRF-Token': getToken() };
|
|
args.success = data => Ember.run(null, resolve, data);
|
|
args.error = xhr => Ember.run(null, reject, xhr);
|
|
Ember.$.ajax(args);
|
|
});
|
|
}
|