samedi 5 août 2017

Customize request format in Ember

I am building a Rails 5 backend API which will receive requests from my Ember app. However I'm having some trouble getting Ember to format the request in a way my Rails server understands.

By default, Rails creates controllers to expect parameters in this format, assuming the model is a, say, Car:

"car": {
  "id": "1",
  "name": "Foo",
  "bar": "Bar",
  ...
}

However it looks like Ember is sending requests in this format:

"data": [
  {
    id: "1",
    type: "cars",
    attributes: {
      "name: "Foo",
      "bar": "Bar",
      ...
  }
]

What can I do to make Ember send request payloads in a way my Rails server will understand? Thank you.




Aucun commentaire:

Enregistrer un commentaire