Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import JSONAPIAdapter from "@ember-data/adapter/json-api";
import { computed } from "@ember/object";
import { pluralize } from "ember-inflector";
import { underscore } from "@ember/string";
import ENV from "../config/environment";
export default JSONAPIAdapter.extend({
namespace: "api",
pathForType(type) {
return pluralize(underscore(type));
},
headers: computed(function () {
/* eslint-disable no-undef */
return {
"X-CSRF-Token": ENV.CSRFToken,
"content-type": "application/json"
};
/* eslint-enable no-undef */
})
});
'session.{isAuthenticated,data.authenticated.access_token}',
function () {
const headers = {};
if (this.session.isAuthenticated) {
headers.Authorization = `Bearer ${this.session.data.authenticated.access_token}`;
}
return headers;
},
),
};
if (ENV.apiHost) {
options.host = ENV.apiHost;
}
export default JSONAPIAdapter.extend(DataAdapterMixin, options);