import { inject as service } from '@ember/service';
import DS from 'ember-data';
import config from 'dummy/config/environment';

export default DS.Adapter.extend({

  namespace: `${config.rootURL.replace(/\/$/, '')}/docs`,

  projectVersion: service(),

  project: null,

  shouldBackgroundReloadAll() {
    return false;
  },

  shouldBackgroundReloadRecord() {
    return false;
  },

  findRecord(store, modelClass, id, snapshot) {
    if (modelClass.modelName === 'project') {
      return fetch(`${this.namespace}/index.json`).then(r => r.json());
    } else {
      return store.peekRecord(modelClass.modelName, id);
    }
  }
});

import { inject as service } from '@ember/service';
import DS from 'ember-data';
import config from 'dummy/config/environment';

export default DS.Adapter.extend({

  namespace: `${config.rootURL.replace(/\/$/, '')}/docs`,

  ajax: service(),

  shouldBackgroundReloadAll() {
    return false;
  },

  shouldBackgroundReloadRecord() {
    return false;
  },

  findRecord(store, modelClass, id, snapshot) {
    if (modelClass.modelName === 'project') {
      return this.get('ajax').request(`${this.namespace}/index.json`);
    } else {
      return store.peekRecord(modelClass.modelName, id);
    }
  }
});

Replace fetch with ajax service
[bugfix] Replace fetch with ajax service
