- I am using a ‘JSONAPIAdapter’ and have my own serializer.
- When a call to my backend succeeds the serializers ‘normalizeResponse’ gets called correctly.
- However if a call fails the serializer never gets called.
- My backend is sending a meaningful message if the call fails and I want to show the message in the UI.
- Currently it seems like a failure payload is not being bubbled up.
- 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?
- So the response I get from my backend is as follows (content is JSON) - {“error”: true, “message”: “Profile already created for the user”, “return”: }
- 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’.
- 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!