Hi,
Would it be possible, for coding comfort, to add the original request URL to the onFailure callback of both GET and POST requests (http://docs.crossrider.com/#!/api/app...)?
The reason is that I am making a lot of different calls, and while onSuccess processing is usually different for each (parsing the correct data etc), the onFailure function is more or less the same — just report the connection issue. So it would be nice to use the same function for error processing, yet I would like to be able to know which call the error happened for.
I hope this won't be too much trouble to implement (and if added as a second parameter it won't affect the existing client code).
Help get this topic noticed by sharing it on
Twitter,
Facebook, or email.
Twitter,
Facebook, or email.
-
Hello Anton,
Thanks for your suggestion. I passed it on to the product team to consider for future releases though, if approved, it may take a long to implement due to other ongoing projects. -
-
Hi Shlomo,
Yes, I understand that, thanks for passing to the team :) And it is good to know that you are working on something! -
-
EMPLOYEE
2Hello Anton,
I discussed this further with the dev team and although the idea is not likely to be implemented in the near future, they suggest you can utilize the extensible nature of our platform and customize the request yourself.
To help you on your way, and to serve as an example for others, you can add your requirement i using a few lines of code:// Extend appAPI.request.get method once at beginning of your code
appAPI.request.get = (function() {
var oldRequestGet = appAPI.request.get;
return function(requestDetails) {
oldOnFailure = requestDetails.onFailure;
requestDetails.onFailure = function(httpCode) {
oldOnFailure(httpCode, requestDetails.url);
}
oldRequestGet.call(appAPI.request, requestDetails);
}
}());
// Invoke as many time as required
appAPI.request.get({
url: 'http://example.com',
onSuccess: function(response) {
console.log('Response: '+response);
},
onFailure: function(httpCode, url) {
console.log('Failed GET request. (url:'+url+
', code:'+httpCode+')');
}
}); -
-
Hi Shlomo,
Using JavaScript enclosures for this is a very good idea, thank you! -
-
Hi Shlomo,
I have a different request though in the same area. Would it be possible to add the data that is returned on failed requests to the onFailure callback? For the server side it is possible to send additional information, in JSON format, on, for example, 400 responses. I can see this data when checking the Chrome's DevTools Network tab, yet so far this is not available from within the Crossrider framework.
This would be VERY useful for error processing to perform a relevant action or show a message to the user on the client side.
Best regards,
Anton -
-
EMPLOYEE
1Hi Anton,
Thanks for the request. Obviously, in this scenario creating an enclosure won't help. However, it's something I can put to the product team for consideration for a future release (though it won't be anytime soon).
In order to put the idea forward, please can you let me know how the data would be sent back? Would it be part of the header? -
-
Hi Shlomo,
No, it is the response body. When using Chrome Dev Tools, in Network tab, I can see the response body for a selected XHR request in the Network section — not in Headers tab, but in Preview and Response tabs.
Thanks for trying to get this feature into the framework!
Best regards,
Anton- view 1 more comment
-
-
Hi Shlomo, is there an update on this? Being able to get contents of failed responses will significantly improve error feedback in our extension (and probably will be helpful to anyone calling an API from Crossrider extensions).
-
-
Our product and dev teams are currently busy on other projects there is no further update on this request at this time.
-
-
-
Loading Profile...




