You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable

you provided 'undefined' where a stream was expected angular 7
you provided an invalid object where a stream was expected boost mobile
you provided 'undefined' where a stream was expected forkjoin
you provided 'undefined' where a stream was expected angular 9
rxjs
you provided 'undefined' where a stream was expected switchmap
rxjs typeerror you provided undefined where a stream was expected
typeerror you provided function memoized

Say I have the following function references:

const externalRequests = (params) => Rx.Observable.zip(
  externalApi1(params),
  externalApi2(params)
)

and

const internalDB = (params) => Rx.Observable.fromPromise(getStuffFromDB(params)

externalRequests returns something of the shape:

{ _isScalar: false,
  source: 
   { _isScalar: false,
     source: { _isScalar: false, array: [Object], scheduler: undefined },
     operator: { project: [Object] } },
  operator: undefined }

and can be .subscribe'd to.

internalDB, when .then'd directly returns the right data from the database, and when wrapped in Rx.Observable.fromPromise as above, returns something of the shape:

{ _p: 
   { handle: 115,
     type: 'promise',
     className: 'Object',
     constructorFunction: { ref: 122 },
     protoObject: { ref: 123 },
     prototypeObject: { ref: 1 },
     status: 'pending',
     promiseValue: { ref: 1 },
     properties: [],
     internalProperties: [ [Object], [Object] ],
     text: '#<Promise>' },
  _s: {} }

, which, when .subscribe'd directly returns something like so:

{ isStopped: false,
  observer: 
   { isStopped: false,
     _onNext: [Function: val],
     _onError: [Function: val],
     _onCompleted: [Function: val] },
  m: 
   { isDisposed: false,
     current: { isDisposed: false, current: null } } }

Say I now want to flatten all of this into a single stream: so I write something like:

Rx.Observable.zip(externalRequests, internalDB).mergeAll().subsribe(() => console.log('potato'))

And receive an exception of the form: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

To summarize: What is the correct way for me to cast my promise as an Observable, and how do I merge/flatten multiple observables as above?

As @martin mentioned you give functions to the zip operator, not observables.

You need to call those functions with the needed params for your code to work.

Also, I don't think you need the mergeAll call, as the result of internalDB and externalRequests calls are only observables, not higher order observables (observables containing observables)

Rx.Observable
  //    ▼ you need to call the functions in order to get their observables
  .zip(externalRequests(params), internalDB(params))
  .subscribe(() => console.log('potato'))

TypeError: You provided an invalid object where a stream , TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. #2125. TypeError: You provided an invalid object where a stream was expected. You can provide an Observable , Promise , Array , or Iterable angular observables rxjs typescript

usually it's because you imported zip from 'rxjs/operators'

you should import zip from 'rxjs/observable'

TypeError: invalid object where a stream was expected (rxjs 6.2.0 , TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. Source mapped: TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.

my mistake to import file like this...

import {loginEpic} from "./Epic";

and i just correct this like...

import loginEpic from "./Epic";

TypeError: You provided an invalid object where a stream - html, TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable - angular. TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. Code: (breaks on Observable.from) componentDidMount() { thi

es6/util/subscribeToResult.js, invalid object' : `'${result}'`;; const msg = `You provided ${value} where a stream was expected.` + ' You can provide an Observable, Promise, Array, or Iterable� You can provide an Observable, Promise, Array, or Iterable (4) 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.

TypeError: You provided an invalid object where a stream was , You can provide an Observable, Promise, Array, or Iterable. you provided an invalid object where a stream was expected boost mobile you provided ' undefined'� ERROR TypeError: You provided 'undefined' where a stream was expected. * You can provide an Observable, Promise, Array, or Iterable. So, my hypothesis is: implementing the ImMemoryWebApiModule interfers (in my case) the HttpClient process in such a way, it removes or deletes information on the request sending to the api. See screenshot

Resolve! TypeError: You provided 'undefined' where a stream was , TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable. I'm glad to hear it helped! On a side note, I don't understand why you use .share(), in the current caseIt should mainly be used when you need real asynchronous behaviour, transferring ownership from the subscription caller to the data source, expecting multiple events to happen from it along its lifetime, and in order to use automatic ref-counted cleanup and source re-construction when

Comments
  • My guess is that the problem is in internalDB which is a method returning an Observable. It's not an Observable itself so zip() can't subscribe to a method. Anyway if you don't provide stackoverflow.com/help/mcve it's hard to tell...