javascript - $http in Ionic app not catching errors -
i'm running ionic android app under genymotion emulator.
i'm having problem $http. when request successful it's fine. when request return 401/403/404 code, exception thrown in ionic framework: ionic.bundle.js
line 17288:
"cannot read property 'data' of undefined", response undefined.
it seems ionic intercepts responses, , 401/403/404 errors still tries trigger .success() callback. see attached excerpt ionic.bundle.js
:
ionic version: 1.0.0-rc.0
the issue caused because had http interceptor in app.js. seemed harmless commenting out solved problem. seem below got commented out:
// .config(['$httpprovider', function($httpprovider) { // $httpprovider.interceptors.push(function() { // return { // 'responseerror': function(rejection) { // var message = "http error " + rejection.statustext + "(" + rejection.status + ") on " + rejection.config.method + " " + rejection.config.url; // // if (typeof rejection.data !== 'undefined') // message += " error response: " + json.stringify(rejection.data); // // // same above // if (typeof _errs !== 'undefined') // _errs.push(new error(message)); // else // console.log(message); // } // }; // }); // }])
Comments
Post a Comment