How to use the ember-data.RESTAdapter function in ember-data

To help you get started, we’ve selected a few ember-data examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apache / ambari / contrib / views / files / src / main / resources / ui / app / adapters / application.js View on Github external
* with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import DS from 'ember-data';
import Ember from 'ember';
import ENV from 'files-view/config/environment';

export default DS.RESTAdapter.extend({
  init: function () {
    Ember.$.ajaxSetup({
      cache: false
    });
  },

  namespace: Ember.computed(function() {
    var parts = window.location.pathname.split('/').filter(function(i) {
      return i !== "";
    });
    var view = parts[parts.length - 3];
    var version = '/versions/' + parts[parts.length - 2];
    var instance = parts[parts.length - 1];

    if (!/^(\d+\.){2,3}\d+$/.test(parts[parts.length - 2])) { // version is not present
      instance = parts[parts.length - 2];
github apache / incubator-pinot / thirdeye / thirdeye-frontend / app / adapters / base.js View on Github external
import DS from 'ember-data';
import { inject as service } from '@ember/service';

const S_401_UNAUTHORIZED = 401;

/**
 * @summary This base supports the standard advanced configurations needed for making the requests.
 */
export default DS.RESTAdapter.extend({
  session: service(),
  shareDashboardApiService: service('services/api/share-dashboard'),
  headers: {
    'Accept': '*/*'
  },
  ajaxOptions() {
    let ajaxOptions = this._super(...arguments);

    //TODO: update this to use another hook - lohuynh
    if (ajaxOptions.data.shareId) {
      delete ajaxOptions.data.shareId;//remove from query as not needed for actual request
    }
    // when server returns an empty response, we'll make it valid by replacing with {}
    ajaxOptions.converters = {
      'text json': function(data) {
        return data === '' ? {} : JSON.parse(data);
github transitland / feed-registry / app / application / adapter.js View on Github external
import DS from 'ember-data';
import Ember from 'ember';

import ENV from 'feed-registry/config/environment';

export default DS.RESTAdapter.extend({
  host: ENV.datastoreHost,
  namespace: 'api/v1',
  coalesceFindRequests: true,
  pathForType: function (type) {
    // model names should be underscored in URLs
    // For example: /api/v1/feed_version_imports
    let decamelized = Ember.String.decamelize(type);
    let underscored = Ember.String.underscore(decamelized);
    return Ember.String.pluralize(underscored);
  },
  ajaxOptions: function (url, type, options) {
    var hash = this._super(url, type, options);
    // only need to include api_key when making GET requests
    // because those are the most frequent type of request.
    // if we include api_key in POSTs or PUTs, Datastore will barf
    //
github mozilla / fxa / packages / fxa-oauth-console / app / adapters / application.js View on Github external
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import Ember from 'ember';
import DS from 'ember-data';
import config from '../config/environment';

function fixUpRedirectUri(uri) {
  if (!uri) {
    // add some defaults, oauth server requires these fields
    uri = 'http://';
  }

  return uri.trim();
}

export default DS.RESTAdapter.extend({
  _handleErrorResponse: function() {
    this.get('session').invalidate();
  },
  session: Ember.inject.service('session'),
  /**
   * API Namespace
   */
  namespace: 'v1',
  /**
   * API Host
   */
  host: config.servers.oauthInternal,
  /**
   * Request headers
   *
   * Sets Authorization headers
github getslash / backslash / webapp / app / adapters / application.js View on Github external
import { underscore } from '@ember/string';
import { pluralize} from 'ember-inflector';
import DS from "ember-data";

export default DS.RESTAdapter.extend({
  namespace: "rest",

  pathForType: function(type) {
    var plural = pluralize(type);
    return underscore(plural);
  },

  ajax: function(url, type, options) {
    return this._super(url, type, options).catch(function(error) {
      error.errors.forEach(function(e) {
        if (e.status === "404") {
          // Replace Ember's default message for 404
          error.not_found = true;
        }
      });
      throw error;
github apache / ambari / contrib / views / hive20 / src / main / resources / ui / app / adapters / application.js View on Github external
* with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import Ember from 'ember';
import DS from 'ember-data';
import ENV from 'ui/config/environment';

export default DS.RESTAdapter.extend({
  ldapAuth: Ember.inject.service(),

  init: function () {
    Ember.$.ajaxSetup({
      cache: false
    });
  },

  namespace: Ember.computed(function () {
    var parts = window.location.pathname.split('/').filter(function (i) {
      return i !== "";
    });
    var view = parts[parts.length - 3];
    var version = '/versions/' + parts[parts.length - 2];
    var instance = parts[parts.length - 1];
github cosmicjs / ember-real-estate-website / cosmic-real-estate / tmp / broccoli_merge_trees-input_base_path-Fxx3KVbZ.tmp / 7 / adapters / listing.js View on Github external
import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  host: 'https://api.cosmicjs.com/v1/cosmic-real-estate',
  urlForFindAll(modelName, snapshot) {
    let path = this.pathForType(modelName);
    return this.buildURL() + '/object-type/' + path;
  },
  urlForFindRecord(slug) {
    return this.buildURL() + '/object/' + slug;
  }
});
github terminalvelocity / blog-seeds-example-application / frontend / app / adapters / user.js View on Github external
import DS from 'ember-data';
import config from '../config/environment';

export default DS.RESTAdapter.extend({
  coalesceFindRequests: true,
  namespace: 'api/v1',
  host: `${config.apiURL}`
});
github terminalvelocity / blog-seeds-example-application / frontend / app / adapters / posts.js View on Github external
import DS from 'ember-data';
import config from '../config/environment';

export default DS.RESTAdapter.extend({
  coalesceFindRequests: true,
  namespace: 'api/v1',
  host: `${config.apiURL}`
});
github zzarcon / spotyness / app / adapters / application.js View on Github external
import DS from "ember-data";

export default DS.RESTAdapter.extend({

});