I am trying to map from a service call but getting an error.
Looked at subscribe is not defined in angular 2? and it said that in order to subscribe we need to
I wrote this because I arrive here searching for the same error, and this could be useful for someone in the future.
I get the same error while trying to initialize a service variable from its constructor making a call to a remote API trough http.get and .subscribe()
After many tests without understanding what the problem was, i finally get it: My application had authentication and an HttpInterceptor, and i was trying to initialize the service calling a public API method using http.get(...) without 'No-Auth' headers. I added them like here, and problem solved for me:
getData() {
var reqHeader = new HttpHeaders({ 'Content-Type': 'application/x-www-urlencoded','No-Auth':'True' });
return this.http.get(environment.urlApi.Literales, { headers: reqHeader });
}
What a headache :(