Resolve! TypeError: You provided ‘undefined’ where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

In one of my Angular 8 project, there was an API call of type GET, but strangely I was not able to make any call to server and error callback displaying this error:

TypeError: You provided ‘undefined’ where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

The code causing trouble!

Here I am sharing snippets of code that were causing this issue. In the next section, I will share how it is resolved.

    this.http.get('https://www.example.com/api/app/dataset/somedatalist')
    .subscribe((resp: any) => {
      console.log(resp);
    }, err => {
      console.log(err);
    });

Just a simple HTTP get a call on the server

How I resolved! this?

This issue was caused due to Interceptors in the applications, so it was resolved by setting 'No-Auth' to 'True' in the request Header as shown below:

    const reqHeader = new HttpHeaders({ 'Content-Type': 'application/json', 'No-Auth': 'True' });
    this.http.get('https://www.example.com/api/app/dataset/somedatalist', { headers: reqHeader })
    .subscribe((resp: any) => {
      console.log(resp);
    }, err => {
      console.log(err);
    });

After setting API call returned success callback.

1 thought on “Resolve! TypeError: You provided ‘undefined’ where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top