Anything like AngularJS's $http.pendingRequests in Angular's HttpClient - angularjs

I was working on AngularJS before and I know there is a build-in property called $http.pendingRequests which can tell me if there is any pending http request existing.
Now I am working on Angular 4.4.6 and using HttpClient from #angular/common/http.
My Goal
I would like to use such result to display a loading message when any http request happens and hide it when all requests finish.
My Search
Did NOT get any luck via search or going through all the #angular/common/http source codes.
My Question
How can I find if there is any pending http request existing.
Or I have to implement it by myself?
Thanks in advance.

Related

How to remove server headers from the response of application insights request (angular-applicationinsights library)

I'm using angular-applicationinsights library in my angularjs app. How to remove server and x-powered-by header from the response. Since its document page does not contain any information regarding this, can you please help me on this?
Note: httpinterceptor does not catch its request and responses

Node-Red flow deploy using http request

I am referring this example https://github.com/watson-developer-cloud/node-red-labs/tree/master/starter-kits/ok_watson and could successfully deploy it in Node-Red. But in this sample the input is Inject based. Is there a way of deploying this same example onto a page using HTTP request or maybe Websocket? I figured we can use http request and response for that, but how should the template code look like if i need microphone and audio out in my http webpage. Thanks in advance.
Yes it is. The flows require a text input, which could easily come from a HTTP form. So add a HTTP Input, HTTP Response and Template with a form, and you should have your text input.

Why same API used in WebApp takes way more time than Normal Rest Client or browser (GET Request)?

I am so much confused after looking at response time of Same API Used in WebApp (Written in AngularJS) takes way more time (~15s) then normal rest client like postman (~4s).
Here's the api:
http://api.airpollution.online/all/public/devices
It's getting used in open airpollution project (under IndiaOpenData Association) webapp :
http://openenvironment.indiaopendata.com
WebApp is using AngularJS's $http to make http call to server.
Can anyone please help me with this?
Thanks in advance.

Preventing similar POST requests with AngularJS

I am currently building a dashboard page with multiple widgets. Those widgets retrieve their data with REST calls ($resource). A few widgets make similar calls and I don't want to DDOS our server so I am looking for a way to make a call only once and resolve all similar requests with the same response.
Since I am restricted to using POST requests only, I cannot use the cache option that $resource offers. This seems to be doing exactly what I want but only for GET requests.
I was thinking along the lines of using a http interceptor to queue similar POST requests, fire only one of them and resolving them all when the first one gets its response.
However, I cannot seem to put the pieces together so any help is appreciated. I am open to other options.
Kind regards,
Tim
Services in AngularJS are singletons, so a solution would be to store the response in the service, as a variable. Then next time you'll do the request, previously check if the variable is null, if it's not you wrap it in a promise and returned it. If it's null, then you do the request, and store the response for the next call.
You can also either use this in your request service or in your interceptor service.
I hope I helped !
Refactor your widgets to depend on a service (singleton).
This service should either poll the server via XHR, or get server push via websocket for updates.
If polling, look into server side caching and etags.

Get request to Json does it need jsonp

I am using Angular v1.2.15 to GET a URL to retrieve JSON results.
I need to send a custom AUTHENTICATION Header with the request.
the url will send back Json.
So far I can only get both $resource and $http to even send the request
if I use JSONP type of request. However when I do this it does not send
my CUSTOM HEADER. Can I retrieve JSON content using a normal GET request?
The problem was the Ripple Emulator for Cordova apps was running the proxy on a different port. The the emulator was actually not allowing the http request.

Resources