Issue
How to wait only for certain time to get the response of HTTP request (GET/POST) in angular 2 otherwise break the HTTP request?
I had a look on timeout
and setTimeInterval
functions but those do not break the HTTP request within specified time limit.
Basically, what I am trying to do is break the HTTP request (whether get or post) if it doesn't get the response within 5 seconds.
Solution
You can use rxjs timeout() and pass time in miliseconds.
this.http.get('url').timeout(5000).map(data => data.json());
Answered By - Igor Janković
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.