Last active
April 12, 2017 22:19
-
-
Save glutengo/8d89843c5693b66317ce39f79886478d to your computer and use it in GitHub Desktop.
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
| public interceptBefore(request: InterceptedRequest): InterceptedRequest { | |
| this.blockUI.load(); | |
| var token = this.auth.getToken(); | |
| if(token) { | |
| request.options.headers.set('x-access-token',token); | |
| } | |
| return request; | |
| } | |
| public interceptAfter(response): InterceptedResponse { | |
| this.blockUI.stop(); | |
| var jsonResponse = response.response.json(); | |
| if(response.response.ok === false) { | |
| var message = jsonResponse.message; | |
| this.snackBar.open(message, 'Error', {duration: 5000}); | |
| } | |
| if(response.response.status === 401) { | |
| this.auth.logout(); | |
| } | |
| return response; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment