So, I have a backend rails application running which is responding for a particular request as follows
{"id": 68,"name": "name","email": "email"}
But in ember, I'm getting this error
Error: Assertion Failed: normalizeResponse must return a valid JSON API document:
* One or more of the following keys must be present: "data", "errors", "meta".
at Object.assert (index.js:163)
at normalizeResponseHelper (-private.js:7428)
at -private.js:13291
at Backburner._run (backburner.js:1010)
at Backburner._join (backburner.js:986)
at Backburner.join (backburner.js:757)
at -private.js:13287
at tryCatcher (rsvp.js:335)
at invokeCallback (rsvp.js:506)
at publish (rsvp.js:492)
I tried wrapping everything under a 'data' array, then I got this error
Error: Assertion Failed: normalizeResponse must return a valid JSON API document:
* Top level of a JSON API document must be an object
at Object.assert (index.js:163)
at normalizeResponseHelper (-private.js:7428)
at -private.js:13291
at Backburner._run (backburner.js:1010)
at Backburner._join (backburner.js:986)
at Backburner.join (backburner.js:757)
at -private.js:13287
at tryCatcher (rsvp.js:335)
at invokeCallback (rsvp.js:506)
at publish (rsvp.js:492)
How do I normalize it all and where, backend or frontend?
update: I made a hash response = {:data=>@user}, and then returned response.to_json I got this
Error: Assertion Failed: Encountered a resource object with an undefined type (resolved resource using (unknown))
at Object.assert (index.js:163)
at Class._normalizeResourceHelper (json-api.js:183)
at Class._normalizeDocumentHelper (json-api.js:133)
at Class._normalizeResponse (json-api.js:228)
at Class.normalizeSingleResponse (json.js:407)
at Class.normalizeSaveResponse (json.js:393)
at Class.normalizeCreateRecordResponse (json.js:351)
at Class.normalizeResponse (json.js:232)
at normalizeResponseHelper (-private.js:7421)
at -private.js:13291
Aucun commentaire:
Enregistrer un commentaire