Last active
August 29, 2015 14:25
-
-
Save fivetanley/5a2208b2e38c7742630d to your computer and use it in GitHub Desktop.
yo iheanyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const {Promise} = Ember.RSVP; | |
export default Ember.Route.extend({ | |
model() { | |
var slug = params.id; | |
return new Promise((resolve, reject) => { | |
$.getJSON(`/api/posts/${slug}`).then((payload) => { | |
let id = payload.post.id; | |
let postAdapter = this.store.serializerFor('post'); | |
let Post = this.modelFor('post'); | |
let normalized = postAdapter.normalize(Post, payload); | |
this.store.push(normalized); | |
resolve(this.store.findRecord('post', id)); | |
}).catch(reject); | |
}); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"post": { | |
"id": 1, | |
"name": "Iheanyi is a rad person who's going to go places" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment