0

I am trying to use get method of http service, but nothing is working.

import { Http, Response, Headers } from '@angular/http';

...

constructor (private http: Http) {}

...

    return this.http.get(this.url)
      .map((...a) => console.log(a))
      .catch(this.handleError);

I cant even see nothing in network related to my url.

What can be wrong?

gkucmierz
  • 1,055
  • 1
  • 9
  • 26
  • You probably forgot to subscribe to the returned observable. That's what sends the request. – JB Nizet Feb 15 '17 at 18:39
  • oops. I still not used to that observables. I was expecting map will show something. But probabli as soon as I not subscribe nothing will be called, right? – gkucmierz Feb 15 '17 at 18:40
  • 1
    Right. map() just returns a new observable which will, when the an event is emitted by the first one, trasform this event. Subscribing is what sends the request. – JB Nizet Feb 15 '17 at 18:44

0 Answers0