lundi 6 juillet 2015

which hook to use for embedded records json normalization

as the server returns JSON that should be preprocessed I wonder what is the best hook to use to munge embedded records. Here is example of the payload from server

{
 "id": 1,
 "first_name": "John",
 "phones": [
   {
     "id": 1,
     "number": "1234567890",
     "type": "main"
   }
 ],
}

and here is how it should looks like in the end:

{
 "id": 1,
 "first_name": "John",
 "phones": [
   {
     "id": 1,
     "number": "1234567890",
     "kind": "main",
     "contactable_type": "User",
     "contactable_id": "1",
   }
 ],
}

ember-data version is 1.13, should I go with normalizeResponse or there is a more appropriate way?




Aucun commentaire:

Enregistrer un commentaire