angularjs - Angular HTTP Interceptor - $q.when - what does it do? -



angularjs - Angular HTTP Interceptor - $q.when - what does it do? -

while browsing blogs , looked @ examples, within angular services found right after handling of http status codes such lines of code:

return response || $q.when(response);

or

return $q.reject(rejection);

what $q.when , $q.reject(rejection) mean , why boolean "or" ?

you can pass $q.when promise or type. if passed parameter not promise - so wrap in promise , phone call resolve. if useful when dealing object may or may not not promise.

the statement response || $q.when(response) means can homecoming value or promise.

my guess - if response null homecoming promise - asynchronously resolve given value - null.

$q.reject(reason) returns rejected promise reason rejected. way of throwing error promise can handled catch.

angularjs

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -