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
This error happened to me @angular 7
You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
The error is actually self-explanatory, it says somewhere
in the observable I pass the invalid object. In my case, there was lots of API call but all the calls were failing because of wrong server configuration. I tried to use map
, switchMap
, or other rxjs operator but the operators are getting undefined objects.
So double-check your rxjs operator inputs.
I have been facing this issue when trying to authenticate a user using JSON Web Token. in my case it's related to authentication interceptor.
Sending a request to authenticate a user doesn't have to provide a token since it doesn't exist yet.
Check that your interceptor include this:
if (req.headers.get('No-Auth') == "True")
return next.handle(req.clone());
And that you provide {'No-Auth':'True'}
to your header's request like this:
authenticateUser(user): Observable<any> {
const headers = new HttpHeaders({'No-Auth':'True'});
headers.append('Content-Type', 'application/json');
return this.httpClient.post(`${this.apiEndpoint}/auth/authenticate`, user, {headers: headers});
}