Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Created April 6, 2015 11:42
Show Gist options
  • Save RyanHirsch/7a86f4a55bc9226fdb40 to your computer and use it in GitHub Desktop.
Save RyanHirsch/7a86f4a55bc9226fdb40 to your computer and use it in GitHub Desktop.
Ember Spotify Adapters and Serializer
// app/album/adapter.js
import ApplicationAdapter from '../adapters/application';
export default ApplicationAdapter.extend({
host: 'http://api.spotify.com',
namespace: 'v1'
});
// app/adapters/application.js
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
});
// app/album/model.js
import DS from 'ember-data';
var attr = DS.attr;
export default DS.Model.extend({
name: attr('string'),
popularity: attr('number'),
release_date: attr('string')
});
// app/album/serializer.js
import DS from 'ember-data';
export default DS.RESTSerializer.extend({
extractSingle: function(store, type, payload, id) {
return this._super(store, type, { album: payload }, id);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment