added a interceptor in ther services to handle the server request error

This commit is contained in:
Mario Colque 2014-01-14 14:48:25 -03:00
parent ce1fde9aa7
commit c3a6c0387c
3 changed files with 42 additions and 0 deletions

View File

@ -3,6 +3,20 @@
angular.module('mystery.address').factory('Address', ['$resource', function($resource) { angular.module('mystery.address').factory('Address', ['$resource', function($resource) {
return $resource('/api/addr/:addrStr', { return $resource('/api/addr/:addrStr', {
addrStr: '@addStr' addrStr: '@addStr'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
}); });
}]); }]);

View File

@ -3,6 +3,20 @@
angular.module('mystery.blocks').factory('Block', ['$resource', function($resource) { angular.module('mystery.blocks').factory('Block', ['$resource', function($resource) {
return $resource('/api/block/:blockHash', { return $resource('/api/block/:blockHash', {
blockHash: '@blockHash' blockHash: '@blockHash'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
}); });
}]); }]);

View File

@ -3,6 +3,20 @@
angular.module('mystery.transactions').factory('Transaction', ['$resource', function($resource) { angular.module('mystery.transactions').factory('Transaction', ['$resource', function($resource) {
return $resource('/api/tx/:txId', { return $resource('/api/tx/:txId', {
txId: '@txId' txId: '@txId'
}, {
get: {
method: 'GET',
interceptor: {
response: function (res) {
return res.data;
},
responseError: function (res) {
if (res.status === 404) {
return res;
}
}
}
}
}); });
}]); }]);