2
votes

Currently we are upgrading our project to work with Ember 2.0 and Ember Data 2.0.

I have model which is based on fixture adapter. But when i do store.findAll(modelName) on the model, i get the following error "TypeError: serializer.normalizeResponse is not a function at ember$data$lib$system$store$serializer$response$$normalizeResponseHelper "

Model

import DS from 'ember-data';
import FixtureData from '<from somewhere>';
var Model = DS.Model.extend({
    code: DS.attr('string'),
    description: DS.attr('string')
});
Model.reopenClass({
    FIXTURES: FixtureData
});
export default Model;

Adapter

import DS from 'ember-data';
export default DS.FixtureAdapter.extend({
    queryFixtures: function (records, query) {
        return records.filter(function (record) {
            for (var key in query) {
                if (query.hasOwnProperty(key)) {
                    if (record[key] !== query[key]) {
                        return false;
                    }
                }
            }
            return true;
        });
    }
});

Error Stack

TypeError: serializer.normalizeResponse is not a function at ember$data$lib$system$store$serializer$response$$normalizeResponseHelper (http://localhost:4201/assets/vendor.js:66323:43) at http://localhost:4201/assets/vendor.js:66627:25 at Object.Backburner.run (http://localhost:4201/assets/vendor.js:9692:25) at ember$data$lib$system$store$$Service.extend._adapterRun (http://localhost:4201/assets/vendor.js:71877:33) at http://localhost:4201/assets/vendor.js:66626:15 at tryCatch (http://localhost:4201/assets/vendor.js:59683:14) at invokeCallback (http://localhost:4201/assets/vendor.js:59698:15) at publish (http://localhost:4201/assets/vendor.js:59666:9) at http://localhost:4201/assets/vendor.js:39006:7 at Queue.invokeWithOnError (http://localhost:4201/assets/vendor.js:10395:18)

2

2 Answers

3
votes

FixtureAdapter has been deprecated in Ember Data 1.0b19 which was released June 5 2015. This is noted in few places and tutorials have yet to catch up:

Sources:

As an alternative to FixtureAdapter you can use Ember Mirage which fills the same role while also providing few other features.

0
votes

Also on the ember-data-fixture-adapter github page, they recommend to use PretenderJS now. https://github.com/pretenderjs/pretender