The interceptors are service factories that are registered with the `$httpProvider` by adding them to the `$httpProvider.interceptors` array. The factory is called and injected with dependencies (if specified) and returns the interceptor.
1
vote
1answer
29 views
Getting the URL entered in browser before redirection in AngularJS?
I'm trying to get the params of the URL originally entered in the browser. But angular "redirects" me automatically to '/'
For example, I enter this URL : http://localhost:9080/#/test?param1=en&...
0
votes
1answer
18 views
Intercept URL parameters and store them in a service
I'm trying to intercept the entered URL, getting its parameters, storing them in a service (that can be used by other services) then redirecting to /.
var config = function (AppConfig, $...
0
votes
3answers
44 views
How to abort or cancel an Angularjs $resource request and override the response by a local data
In one of my new projects I am using AngularJS $resources for http calls. I have requirement to show local data (from SQLite) when there is no internet connection.
I have clustered my obstacles by ...
0
votes
2answers
29 views
Cannot intercept 401 Angular
I have been trying to intercept 401 responses when I hit an API but it has been frustratingly not working at all.
When I visit a particular link, on the browser console, I can see that it is ...
0
votes
0answers
8 views
Angular HttpInterceptor errorResponse has the wrong status
The server returns a 403 Forbidden status, but angular interceptor retrieves a -1 status... any ideas?
Options request returns a 200 OK...
0
votes
1answer
12 views
HttpRequestInterceptor display multiples times the same error
I added a HttpRequestInterceptor insie my AngularJS app to display a toastr every time a request fails.
angular.module('spwApp.factories')
.factory('httpRequestInterceptor', ['$q', '$injector', '$...
11
votes
2answers
4k views
Reject from 'response' into 'responseError'
Sometimes, the API I'm using will return 200 ok even though there has been an error. The response JSON object will look something like:
{
error: true
}
I've built a $http response interceptor ...
0
votes
0answers
30 views
How to selectively disable Angular HTTP Interceptor
I have an HTTP interceptor that does ref counting on the active requests (+1 for request, -1 for requestError, response, & responseError). The ref count value is used to show/hide a loading ...
0
votes
0answers
30 views
How to use notification in httpinterceptor angularjs
I'd like to use Notification in my interceptor. It's seams that i can't because there is circular dependency problem:
Here is my Code Configuration
`
var app = angular.module("myApp", ['...
0
votes
1answer
15 views
AngularJS - Put $http interceptor in separate file
How can I put my interceptor in a separate file and push it in the $httpProvider within the configuration block.
Here's my configuration block at the moment:
(function() {
'use strict';
angular
...
0
votes
1answer
32 views
AngularJS 1.x TypeScript (with Webpack) Interceptor issue
I've just started on TypeScript, so I think it is something very silly.
I've gone through couple of dozens links but can't find exactly what is the issue that my service instance is undefined.
So my ...
0
votes
2answers
34 views
Need to call AngularJS function on every ajax request
I need to call one of my AngularJS function on every Ajax request that my application makes and I want to do it AngularJS Way (not a classic JS/JQuery Way)
Here is my code :
.config(['$httpProvider'...
0
votes
2answers
54 views
Cannot read property 'push' of undefined in $httpInterceptor
I want to send a default data parameter for all the $http requests in my app.
I referred to this answer $httpInterceptor. I can able to set default headers, but for parameters its not working. I ...
0
votes
0answers
16 views
Show Spinner for $Http requests using Interceptors
I am new to AngularJS. Can anyone show me how to get a spinner for the http requests using Interceptors.
Thanks in advance
3
votes
0answers
40 views
Why injecting `$http` in angular 1 error interceptor cause circular dependency? [duplicate]
Consider the following interceptor template for angular 1
(function () {
'use strict';
angular
.module('myApp')
.factory('apiError', apiError);
...
0
votes
1answer
36 views
Angular http interceptor response function removes message param from server response
In my application all server responses are as follows:
response = {
data: {},
status: STATUS_CODE,
message: STRING_MESSAGE
}
I want to use angular's http response function to display a ...
4
votes
3answers
352 views
Using `$mdToast` inside an interceptor triggering circular dependency
Question:
How can I use $mdToast inside an interceptor without triggering the error?
Setup:
Interceptor definition:
(function () {
'use strict';
angular
.module('app.components.http-...
0
votes
0answers
23 views
Angular Bearer Auth Interceptor not generating new token after expiring
I am working on an authentication solution made with Angular using a Bearer Auth Token Interceptor and localStorage, but every time I generate a token and try to acces with a wrong user credentials, ...
0
votes
2answers
122 views
Angularjs $http interceptors - Cannot generate call to requestError
I'm using $http interceptors to capture all events following an ajax submission. For some reason, I am not able to throw a requestError. I've set up a test app to try and call requestError, but so far ...
0
votes
0answers
105 views
angular2 - a loading progressbar for the main page (while angular itself is loading)
is it possible to make a loader progressbar (or just percentage text) in the index.html that tells the percentage of the loading?
I think it will be done with JS not angular2 (since its not loaded ...
0
votes
1answer
150 views
How to access Response body from Angular HTTP Interceptor on failure?
I've got this factory that I'm pushing into the $httpProvider interceptors
function httpErrorHandler($q) {
return {
'responseError': function (response) {
if (response.status =...
2
votes
0answers
74 views
Angular $httpProvider.interceptor not adding header to request
I have what I thought was a very simple http interceptor. It is not working. Here is the code:
$httpProvider.interceptors.push(['$q', '$cookies', function($q, $cookies) {
return {
request: ...
0
votes
0answers
68 views
Show error messages in interceptors based on request options
I want to show a toastr message for all http errors in an interceptor, But sometimes I want to disable showing automatic messages. So I want to pass a disableMessage: true to $http request options and ...
0
votes
1answer
49 views
Updating all api requests using ui-router stateParams and an interceptor
I have a an Angular application that reuses the same templates for several locations. The urls look something like:
/locations/location1/
/locations/location2/
/locations/location1/about
/locations/...
0
votes
0answers
98 views
angularjs read request header
We have a angularjs site which is SSO protected and deployed on our apache webserver.
Once the user is authenticated and authorized for access - the SSO
agent would enrich the http header section ...
0
votes
0answers
22 views
Concurrency on updating token on Angular interceptor
I have a problem updating token expired with interceptor. In my JWT token there is an expiration time and I need to update on request interceptor, the problem is that my application makes some ...
0
votes
0answers
158 views
Angular JS/TypeScript Http Interceptor multiple refresh token calls made
This is similar to the following question AngularJS - http interceptor - resend all request after token refresh and a few others on here.
Using Web Api 2, bearer tokens, TypeScript and AngularJS 1.5....
0
votes
0answers
247 views
Uncaught Error: [$cacheFactory:iid] CacheId '$http' is already taken
I have this problem with CacheFactory where i keep on getting this error Uncaught Error: [$cacheFactory:iid] CacheId '$http' is already taken!
I always get this error when I add httpInterceptors code ...
0
votes
1answer
19 views
Where should I insert or inject interceptor
This is something I have written in my service, Can anyone tell me where and how am I supposed to insert the http interceptor, so that I can check out each response and see if the status code contains ...
0
votes
3answers
129 views
Do $http request from Angular Interceptor?
I'm trying to implement Angular Interceptor for Exceptions. For one at least. I have a token and when it old enogh backend throws TokenAlmostExpired exception. This exception contains errorCode = 101. ...
0
votes
2answers
37 views
How to split interceptor for different requests (URLs)?
At first I've had configAuth with headers, including JWT token at every Controller.
var configAuth = {
headers: {
'Content-Type': 'application/json',
'Authorization': localStorage....
0
votes
0answers
50 views
Passing params to Angular $http redirect request
I'm trying to make the GET request for some resource. In order to access it, I have to pass additional auth params in my url, e.g
?client_id=...&oauth_token=...
The problem is that whenever I ...
1
vote
1answer
45 views
angularjs prevent error from bubbling to httpinterceptor
I have an http interceptor for my angularjs app that catches any http exceptions and handles them. There are a few cases where i would like to catch the error from the request and handle them there, ...
0
votes
2answers
77 views
angularjs http interceptor to show error on loaded location path
I have an application for which I created an interceptor to handle token expirations after 15 minute inactivity, it successfully redirects to the login page after a token has expired, but Im not able ...
0
votes
1answer
134 views
I want to use NGtoast inside service
Below is the code for my service to dispaly Toast
angular.module('messageUIServices', [])
.factory('messageUIServices',
['ngToast',
function (ngToast) {
var service = {};
service.messageType = '...
2
votes
1answer
347 views
ng mock e2e Unexpected Request
I'm using the ngMockE2E to mock the httpBackend while developing the UI in Angular JS. The App runs on a Grizzly-Server with a backend which is provided by a virtual machine. Now when I go on the ...
0
votes
2answers
589 views
Unknown provider: toasterProvider <- toaster <- RugHttpInterceptor <- $http <- ng1UIRouter
I am working on Interceptors to display a toast msg if my app caught a http error in responseError code.
I am using AngularJS Interceptor. It is an MEAN.JS app.
Interceptor Code
angular.module('...
0
votes
0answers
69 views
how to toast a message from http response error to login page [angularjs, node, ecpress]
I am working on displaying an error msg using toast when my response httpinterceptor catch some http error like 401, 500... I am new in this, struggling from hours.
when some http-error caught, my ...
0
votes
0answers
47 views
best way to maintain session using Interceptor (cookies/ server-sessions)
Firstly, apology if this question does not make sense. I am developing code for session management for my mean stack app. From last few days, i found lots of way to implement it which are using either ...
0
votes
1answer
791 views
Uncaught Error: [$injector:unpr] Unknown provider: $cookiesProvider <- $cookies <- YourHttpInterceptor <- $http <- ng1UIRouter
I am getting this error, struggling from hours to solve this. I'm new in MEAN stack development.
I am trying to implement the session management in my app. But stuck at this point.
Error:
...
3
votes
1answer
92 views
how to develop angularjs interceptor to control session
i'm a student, and recently working on angularJS interceptor and trying to develop one to control session management. I am new in mean stack development and need help.
Does anybody have a working ...
0
votes
0answers
17 views
How to make a get/post request in angular module.config function using $httpProvider?
I need to make an http request in the config function itself to load some data before my application controllers fire .i.e.,
angular.module('myApp').config(function($httpProvider){
//How to make ...
0
votes
2answers
97 views
Angular Intercepting a particular http request and prompt for login
I am working on an angular app. It's an SPA. I am loading the profile(or myAccount) page into the home page when user clicks on a link.
<a href="#" ng-click="getProfileData()"/></a>
in ...
0
votes
1answer
113 views
Handle angular http errors using interceptors
My question is what is the best way to handle errors from http REST calls. Should I use interceptors or decorators? My rest functions look something like this:
queryFunction : function (config) {
...
-1
votes
2answers
45 views
Why the interceptor factory is failing when is request in the config file?
I have the next configuration (index.js) to call to my interceptor factory.
angular.module('pasApp')
.factory('InterceptorFactory',['$q','$location',require('./factory-interceptor.js')])
.config(['$...
0
votes
0answers
25 views
Angular: using $httpProvider to prioritize requests based on param
I'm trying to create a queue of http requests and stack them in whatever order I want and execute those requests in that order.. My goal is to create lazy calls (these calls only affect blocks in my ...
0
votes
1answer
73 views
400, 401 error not catched by angularjs http interceptor or $http().catch()
When writing $http() queries i found that nor interceptor configured with
$httpProvider.interceptors.push('myHttpInterceptor') neither $http().catch() never fired with 401 or 400 error. What is ...
0
votes
1answer
99 views
Disable $httpProvider.interceptors.push for a specific url
I have a problem with finding a solution about my $httpProvider in AngularJS.
I have a Accessservice which i handle response Error from server , this service can handle 401,404 .. http errors and make ...
0
votes
2answers
86 views
Angular js interceptor that returns a cached response
I want to make a angularJS interceptor that when the client is offline returns instead of an error a cached response as if it wasn't any error.
What I've done so far was to make an interceptor that ...
0
votes
0answers
20 views
Using Angularjs for authentication channeling through http-auth-interceptors
I have seen materials telling me what http-auth-interceptor is, but how do you actually use in a real life application? Could anybody direct me to a proper usage of this interceptor example? Even when ...