small medium large xlarge

06 Feb 2017, 20:22
John Paul Bamberg (2 posts)
import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  normalize: function(typeClass, hash, prop) {
    hash.title = hash.Title;
    delete hash.Title;
    hash.user = hash.User;
    delete hash.User;
    return this._super(typeClass, hash, prop);
  serialize: function(snapshot, options) {
    var json = {
      Title: snapshot.attr('title'),
      User: snapshot.belongsTo('user').id
    return json;

Uncaught TypeError: Cannot read property ‘id’ of null from User: snapshot.belongsTo('user').id I’m using ember-cli 2.11

08 Feb 2017, 17:30
Matthew White (60 posts)

Can you verify that your code matches the code listings for the chapter? That error sounds like it might occur if you aren’t using a RESTAdapter, but rather a JSONAPIAdapter.

You must be logged in to comment