Post Model different than received model


Hi, I have a requirement where in I have a REST API (Not controlled by me) which needs some JSON data in a specific format as a Post request and returns a JSON response in a different format. My question is, can Ember data be used here? Can I write custom Adapter which modifies the request when we make a find query I can modify the request from ‘get’ to ‘post’ and add the post data and in turn get the data using custom serializer.



Hello @batman. Yes you can do this by creating a custom adapter. You may want to look at the documentation but it sounds like you will want to create a custom find method for your adapter. This could be something as simple as

App.ApplicationAdapter = DS.RESTAdapter.extend({
    find: function(store, type, id) {
        var data = {
            id: id,
            // other JSON data here
        return this.ajax(this.buildURL(type.typeKey, id), 'POST', data);

Please let me know if you run into any trouble creating a custom adapter. I’m working on putting together a guide to cover custom adapters atm.


@bmac Thank you for jumping in on this after catching it on #emberjs! The Ember community once again warms the cockles of my cold, hard, heart.


Thanks for the response :). Bmac if you can share the guide for creating custom adapters that will be great. Thanks a bunch.


The guide is available here

Prs ( ) and feedback welcome.


Thanks a lot Bmac :smile: