Last active
August 29, 2015 14:10
-
-
Save deborasetton/37ee11991e8a68717957 to your computer and use it in GitHub Desktop.
Stuff to refer to later
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * References: | |
| * [1] https://docs.angularjs.org/api/ng/service/$http#interceptors | |
| * [2] http://www.webdeveasy.com/interceptors-in-angularjs-and-useful-examples/ | |
| * | |
| */ | |
| function toasterInterceptor($q, $log, toaster) { | |
| var interceptor = { | |
| request: function (config) { | |
| $log.info("♢ " + config['method'] + ' ' + config['url']); | |
| return config; | |
| }, | |
| requestError: function (rejection) { | |
| $log.error("Request error!"); | |
| return $q.reject(rejection); | |
| }, | |
| response: function (response) { | |
| $log.info("♦ " + response.config['method'] + ' ' + response.config['url'] + ' | ' + response.status + '(' + response.statusText + ')'); | |
| return response; | |
| }, | |
| responseError: function (rejection) { | |
| $log.error("→ " + rejection.config['method'] + ' ' + rejection.config['url'] + ' | ' + rejection.status + '(' + rejection.statusText + ')'); | |
| toaster.pop('error', null, 'Something went wrong'); | |
| return $q.reject(rejection); | |
| } | |
| }; | |
| return interceptor; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get something across all indices by TYPE and ID. | |
| /_all/TYPE/_search?q=id:ID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Gist with some stuff to refer to later. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment