Model getting a URL as a resource


Hi all,

I have a model that gets a URL as a source of data, currently an array of other models. I want to map it as a store and thus I created a model that acts as an intermediate.

This is the schema:


export default DS.Model.extend({
studies: DS.belongsTo('studies-collection-id);


export default DS.Model.extend({
  studies: DS.hasMany('study')


export default ApplicationAdapter.extend({
  urlForFindRecord (id, modelName, snapshot) {

This works fine and I get the request that I need fired and the server responds with the array of studies that I was expecting. The problem is I can’t get those studies to reach the store in any way.

I tried serialising the response but currently have no success on that. I post what I’m using now:


import ApplicationSerializer from './application';

export default ApplicationSerializer.extend({
  primaryKey: 'self',
  normalizeResponse(store, primaryModelClass, payload, id, requestType) {
    let jsonApiStudiesArray = [];
    jsonApiStudiesArray['data'] = payload.slice(0);
    jsonApiStudiesArray['self'] = id;
    jsonApiStudiesArray['type'] = primaryModelClass.modelName;
    jsonApiStudiesArray['data'] = [];
    jsonApiStudiesArray['data']['attributes'] = payload.slice(0).map(function(item){
      let returnArray = [];
      returnArray['type'] = 'study';
      returnArray['self'] = item['self'];
      returnArray['attributes'] = item;
    return this._super(store, primaryModelClass, jsonApiStudiesArray, id, requestType);

Anyone has a suggestion on this?. I feel like I’m trying to hack ember on this and it should be easier. Thank you very much for your help