[SOLVED] How to resolve: Encountered a resource object with an undefined type

Hello, I am not sure what this error is telling me and most of all how to go about fixing it.

Error while processing route: index Assertion Failed: Encountered a resource object with an undefined type (resolved resource using connect@serializer:application:) Error: Assertion Failed: Encountered a resource object with an undefined type (resolved resource using connect@serializer:application:)
    at new Error (native)
    at Error.EmberError (http://localhost:4200/assets/vendor.js:26885:21)
    at assert (http://localhost:4200/assets/vendor.js:16833:13)
    at Object.assert (http://localhost:4200/assets/vendor.js:26655:34)
    at assert (http://localhost:4200/assets/vendor.js:67485:37)
    at _normalizeResourceHelper (http://localhost:4200/assets/vendor.js:79391:41)
    at _normalizeDocumentHelper (http://localhost:4200/assets/vendor.js:79352:25)
    at _normalizeResponse (http://localhost:4200/assets/vendor.js:79436:36)
    at normalizeArrayResponse (http://localhost:4200/assets/vendor.js:80142:19)
    at normalizeFindAllResponse (http://localhost:4200/assets/vendor.js:80012:42)logError @ ember.debug.js:27966defaultActionHandlers.error @ ember.debug.js:27909triggerEvent @ ember.debug.js:28025trigger @ ember.debug.js:52525Transition.trigger @ ember.debug.js:52339(anonymous function) @ ember.debug.js:52159tryCatch @ ember.debug.js:52858invokeCallback @ ember.debug.js:52873publish @ ember.debug.js:52841publishRejection @ ember.debug.js:52776(anonymous function) @ ember.debug.js:31434Queue.invoke @ ember.debug.js:327Queue.flush @ ember.debug.js:391DeferredActionQueues.flush @ ember.debug.js:192Backburner.end @ ember.debug.js:570Backburner.run @ ember.debug.js:692Backburner.join @ ember.debug.js:712run.join @ ember.debug.js:20631hash.success @ rest.js:745fire @ jquery.js:3148self.fireWith @ jquery.js:3260done @ jquery.js:9314callback @ jquery.js:9718

Transition #0: index: transition was aborted

I am fetching data from mongodb via node, my returned data looks like this:

$ curl http://localhost:3000/api/guests

{"data":[{"_id":"56b7ecbc1ef21172377d6159","name":"Ray","message":"First ever guest post entry"},{"_id":"56b7ecbc1ef21172377d615a","name":"Sam","message":"Sam like the new guest post page"}]}

Hi DevGuy, Ember Data is not understanding your API response format. Your app is probably using JSONAPISerializer, which expects something along the lines of

{ data: [ { "id": "56b7ecbc1ef21172377d6159", "type": "guest", "attributes": { "name":"Ray","message":"First ever guest post entry" } }, ... ] } (note the top-level id -no underscore- and type)

For more information you should check out the spec. A few months ago I wrote about customizing adapters and serializers: http://emberigniter.com/fit-any-backend-into-ember-custom-adapters-serializers/

Alternatively, you can use RESTSerializer, check out the Ember docs.


Hi emberigniter,

thanks for the answer, I realized that’s what I had to do after staring long into the ember mirage example. Looking forward to reading your write up after some rest, hopefully it will help me write out the serializer I need to code since I hard-coded some sample data.

1 Like

Hi EmberIgniter, I just wanted to thank you for the awesome article you wrote on Ember JSON serializers, it saved me in real sense, my JSON format was not as per the specs and my attribute keys were in camelCase which were creating issue till the end… but your article was like a torch bearer in my journey in the dark