handleResponse (status, headers, payload, requestData) Object | DS.AdapterError
Takes an ajax response, and returns the json payload or an error.
By default this hook just returns the json payload passed to it. You might want to override it in two cases:
Your API might return useful results in the response headers. Response headers are passed in as the second argument.
Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a
DS.InvalidErroror aDS.AdapterError(or a sub class) from this hook and it will automatically reject the promise and put your record into the invalid or error state.
Returning a DS.InvalidError from this method will cause the record to transition into the invalid state and make the errors object available on the record. When returning an DS.InvalidError the store will attempt to normalize the error data returned from the server using the serializer's extractErrors method.
Parameters:
-
status
Number -
headers
Object -
payload
Object -
requestData
Object - - the original request information
Returns:
-
Object | DS.AdapterError - response
Please login to continue.