mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
Wizard: Step 1
This commit is contained in:
18
app/assets/javascripts/wizard/lib/ajax.js.es6
Normal file
18
app/assets/javascripts/wizard/lib/ajax.js.es6
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
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);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user