jsonapi-serializer icon indicating copy to clipboard operation
jsonapi-serializer copied to clipboard

Error deserializing response with only top-level meta

Open craiggoldstone opened this issue 8 years ago • 1 comments

I have an API which responds to a HTTP DELETE request with the following data (status code 200):

{
  "meta": {
    "status": 200,
    "message": "Foo successfully deleted"
  }
}

AFAIK this is a valid response

The code throws an error with message Cannot read property 'attributes' of undefined. I've created a live demo to reproduce the error: http://requirebin.com/?gist=492af54ce9e9f5220f40c376fa9060c1

I think the code needs some rework to accept a valid JSON API response containing only a top-level meta attribute. I've traced the error in the latest codebase to: image

I'm not exactly sure what I expected the deserialized data to look like, perhaps:

{
    "status": 200,
    "message": "Foo successfully deleted"
}

craiggoldstone avatar Apr 26 '17 13:04 craiggoldstone

:+1: to this. From looking at the code and the tests, it doesn't look like this is equipped to work with or expose top-level meta object of a response. I would love to be able to access the top-level meta, as it's necessary for things like pagination, etc.

mduleone avatar Oct 14 '19 17:10 mduleone