"use strict";
import Ember from 'ember';
import config from '../config/environment';

var csrfTokenRequest;

export default Ember.Object.extend({
  init: function() {
    // Since the CSRF token is used for all other backend requests, we might as
    // well fetch it immediately when the service is loaded.
    this.getCsrfToken();
  },

  getCsrfToken: function () {
    // If the CSRF request was not already created, create it.
    if (!csrfTokenRequest) {
      csrfTokenRequest = Ember.$.ajax({
        contentType: 'application/json',
        dataType: 'json',
        type: 'POST',
        url: config.bookmeisterServer + 'api/bookmeister/user/token.json'
      });
    }

    // Return the promise so it can be used by the caller.
    return csrfTokenRequest;
  }
});


@@ -1,18 +1,4 @@
-%22use strict%22;%0A
 impo
@@ -129,201 +129,8 @@
 d(%7B%0A
-  init: function() %7B%0A    // Since the CSRF token is used for all other backend requests, we might as%0A    // well fetch it immediately when the service is loaded.%0A    this.getCsrfToken();%0A  %7D,%0A%0A
   ge
@@ -417,16 +417,17 @@
 rver + '
+/
 api/book
@@ -556,17 +556,19 @@
 equest;%0A
-
   %7D%0A
+%0A%0A
 %7D);%0A%0A

Stop initial fetch of CSRF token.