I
I
iluxa18102019-03-18 01:01:07
Angular
iluxa1810, 2019-03-18 01:01:07

HttpClient not sending requests without subscribe?

Actually, the question is, is it normal that calling the get method of the HttpClient class, which is not followed by the subscribe method, does not lead to a request to the resource?
The request is like this:

this._httpClient.get('http://localhost:20019/api', { responseType: "text", withCredentials: true });

I also tried to call the pipe method, the same nonsense ...
It turns out that in fact the request would pass, the construction should end with subscribe?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tuwkan, 2019-03-18
@iluxa1810

Yes, observable without subscribe fails

S
shai_hulud, 2019-03-18
@shai_hulud

Try httpClient.get(...).toPromise() , inside there will be a subscription and folding the result into a Promise. And the Promise itself can be "postponed for later" or thrown away :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question