rockandrollwithemberjs / rarwe-issues

Errata and updates for the Rock and Roll with Ember.js book
https://rockandrollwithemberjs.com
43 stars 4 forks source link

The attributes of payload in chapter 9 of version 20211015 #518

Closed waihon closed 3 years ago

waihon commented 3 years ago

On page 125, the saveSong() has a payload with attributes having a key-value pair, i.e. attributes: { title: this.title }.

On page 127, the updateRating() has a payload with just attributes: { rating }.

May I know why { rating } would work and not { rating: rating }?

balinterdi commented 3 years ago

{ rating } is a shorthand for { rating: rating } so both work but you see the short-hand form quite often these days as it's quite elegant (and you don't have to type that much :) ).

You can't use a shorthand for { title: this.title } as this is not the same as { title: title }.