Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import RESTAdapter from '@ember-data/adapter/rest';
import flatten from 'lodash-es/flatten';
import isArray from 'lodash-es/isArray';
import isPlainObject from 'lodash-es/isPlainObject';
import isString from 'lodash-es/isString';
export default RESTAdapter.extend({
// Build the URL using the customizable "urlRoot" attribute that can be set
// on the model class.
buildURL(modelName, id, snapshot) {
if(snapshot && snapshot.type && snapshot.type.urlRoot) {
let url = snapshot.type.urlRoot;
if(id) {
url += '/' + encodeURIComponent(id);
}
return url;
} else {
return this._super(...arguments);
}
},
// Ember data requires that errors from the API be returned as an array. This
import RESTAdapter from '@ember-data/adapter/rest';
import { inject as service } from '@ember/service';
import AdapterFetch from 'ember-fetch/mixins/adapter-fetch';
export default RESTAdapter.extend(AdapterFetch, {
encryption: service(),
// set namespace to api.php in same subdirectory
namespace:
window.location.pathname
// remove index.html if it's there
.replace(/index.html$/, '')
// remove tests prefix which is added by testem (starting with a number)
.replace(/\/\d+\/tests/, '')
// remove tests prefix which is added by tests run in browser
.replace(/tests/, '')
// remove leading and trailing slash
.replace(/\/$/, '')
// add api.php
.concat('/api/index.php')
// remove leading slash