Ember Adapter does not call serializer when call to a backend API fails

  1. I am using a ‘JSONAPIAdapter’ and have my own serializer.
  2. When a call to my backend succeeds the serializers ‘normalizeResponse’ gets called correctly.
  3. However if a call fails the serializer never gets called.
  4. My backend is sending a meaningful message if the call fails and I want to show the message in the UI.
  5. Currently it seems like a failure payload is not being bubbled up.
  6. How can I get access to the payload that was received when a call to the backend fails?

How does the payload looks like when the call fails? Is it a JSON API compliant error? What is the HTTP response status code?

  1. So the response I get from my backend is as follows (content is JSON) - {“error”: true, “message”: “Profile already created for the user”, “return”: }
  2. Since I have my own serializer I thought I should be able to manipulate the response and make it JSON compatible. I use a ‘JSONSerializer’.
  3. HTTP response code is 400.

Some more info: So basically I want to show the ‘message’ from the return payload. But in the following line of code the reject func gets called directly without going via the serializer and the failureData does not contain the raw payload (I was expecting that if it does not go via the serializer). signupRecord.save().then( function(successData) {}, function(failureData) {} }

Actually closing the issue: Figured that I need to add ‘handleResponse’ in my adapter and make the error compatible to what the JSON API expects.

1 Like

I was about to suggest that you make sure the error response was compatible. Glad you found out!