Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Deserialization #207

Open
sepowitz opened this issue Jul 12, 2019 · 1 comment
Open

Error Deserialization #207

sepowitz opened this issue Jul 12, 2019 · 1 comment

Comments

@sepowitz
Copy link

Hey there,

Really liking the lib, but curious why the deserializer doesn't handle json api complicant error messages, and how we should approach error deserialization using this lib.

I am attempting to deserialize a json api error:
Error example:

{
  "errors":[
    {"detail":"Shipping address is invalid","source": 
    {"pointer":"/data/attributes/shipping_address"},"title":"is invalid"}
  ],
"jsonapi":{"version":"1.0"}
}

But am getting a type error, because attributes cannot be found:

TypeError: Cannot read property 'attributes' of undefined
    at extractAttributes (deserializer-utils.js:96)
    at push../node_modules/jsonapi-serializer/lib/deserializer-utils.js.module.exports.perform (deserializer-utils.js:161)
    at resource (deserializer.js:26)
    at deserialize (deserializer.js:38)
    at index.js:51

Any help would be greatly appreciated.

@zimmermanw84
Copy link

I am deserializing the following JSON and am getting the same error.

{
	"data": {
	   "type": "SomeModelType",
	    "attributes": {
	      "name": "Some Custom Option",
               "value": "This is the Value"
	     }
         }
}

Error Message

Debug: handler, error
    TypeError: Cannot read property 'attributes' of undefined
    at extractAttributes (.../node_modules/jsonapi-serializer/lib/deserializer-utils.js:89:37)
    at module.exports.perform (.../node_modules/jsonapi-serializer/lib/deserializer-utils.js:149:13)
    at resource (.../node_modules/jsonapi-serializer/lib/deserializer.js:25:10)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants