Access Http Body On Dojo Request Error
My webservice puts details about the occoured error in the http body. How can I access this details in a dojo request. For example the http error looks like this: HTTP/1.1 500 Inte
Solution 1:
Have a look at my answer to How to retreive XHR response code (+timestamp) of AMD'ized Dojo?
Use deferred.response.then
instead of deferred.then
:
var deferred = request.get("./rest/test/error", { handleAs: "json" });
deferred.response.then(
// success
function(response) {
console.log("data:", response.data); // parsed json
console.log("http body:", response.text); // raw text
},
// error
function(error) {
var response = error.response;
console.log("http body:", response.text);
}
);
See it in action at jsFiddle: http://jsfiddle.net/phusick/SGh5M/
Solution 2:
When I've used dojo for Ajax requests, the error method always had more than one parameter. I think the first param is the request that was sent and the second param is the response or exception.
Try adding a second param to your method and see if that contains what you need.
Post a Comment for "Access Http Body On Dojo Request Error"