How to get a Post model from a post id?

I’m writing a component with an action that opens the composer.

I want to send a REPLY action and reference a specific post.

I can get the post object, no problem:

ajax(`/posts/${this.get('postId')}`).then((post) => {
    composer.open({
        action: REPLY,
        post, // not a Post model
        draftKey: topic.draft_key,
        topicBody: 'some pre-filled text',
      });
})

But how do I get the post model? (I’m sure it’s pretty obvious, but I can’t figure it out)

I need it because otherwise, post.get() in the composer model fails:

1 Like

Ok, found it. I knew it had to be easy :sweat_smile:

import EmberObject from '@ember/object';

ajax(`/posts/${this.get('postId')}`).then((post) => {
    composer.open({
        action: REPLY,
        post: EmberObject.create(post), // now it's an actual model
        draftKey: topic.draft_key,
        topicBody: 'some pre-filled text',
      });
})