Personally, I use a modified version of Witoldz's angular-auth module: https://github.com/witoldsz/angular-http-auth
Basically, intercept all the 401s and stash them, and when the token's been generated, resolve all the 401'd data by re-requesting with the token. e On Wed, May 28, 2014 at 7:48 AM, Dries De Smet <[email protected]>wrote: > How can I use a promise in this case to prevent other requests to be > executed? As far as I could test, the new request will still be fired. > > Op woensdag 28 mei 2014 16:42:40 UTC+2 schreef Rishi Tandon: >> >> Check for Angular promise and deferred objects. >> >> On Wednesday, May 28, 2014, Dries De Smet <[email protected]> wrote: >> >>> Hi, >>> >>> Is it possible in AngularJS to wait before a specific request is done? >>> >>> I'm executing a $http.get() in the run() block of my authentication >>> module to retrieve an access token. After I receive this token, I set the >>> restangular default headers so that future requests can use it >>> >>> Since the run() doesn't wait for the response, it can be that my index >>> page is already requesting data without providing the token. >>> >>> I want to avoid adding checks in every route or service call, so I was >>> curious if I can block other $http requests until the token one is done. >>> >>> On the IRC channel they referred me to http interceptors, but I'm not >>> sure how to use them in this case to achieve what I want. (I already use it >>> to handle 401 errors, but I don't see how I can block other requests with >>> it). >>> >>> Thanks in advance, >>> >>> Dries >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "AngularJS" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at http://groups.google.com/group/angular. >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> -- >> *Rishi Tandon* >> Pearson Learning Technology Group >> >> Mobile: (310) 926-9032 >> >> Pearson >> Always Learning >> Learn more at www.pearson.com >> >> -- > You received this message because you are subscribed to the Google Groups > "AngularJS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/angular. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
