DS.RESTAdapter#handleResponse()

handleResponse (status, headers, payload, requestData) Object | DS.AdapterError

Defined in addon/adapters/rest.js:886
Available since 1.13.0

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:

  1. Your API might return useful results in the response headers. Response headers are passed in as the second argument.

  2. Your API might return errors as successful responses with status code 200 and an Errors text or object. You can return a DS.InvalidError or a DS.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
doc_EmberJs
2016-11-30 16:50:30
Comments
Leave a Comment

Please login to continue.