Angular RxJS Observable loading error

Sumchans

I have declared an observable variable

workOrders: Observable<IWorkOrders[]>;

And then i load that observable this way.

  this.bs.getWorkOrders()
  .pipe(map(data:IWorkOrders[]) => this.workOrders = data)),
    .subscribe((data: IWorkOrders[]) =>
      // this.workOrders = data;
      this.woSubject.next(data),
  );

but when i do it i see a red squiggly under the this.workOrders = data line. And also when I hover it says [ts] Type 'IWorkOrders[]' is not assignable to type 'Observable' enter image description here

Antoniossss

workOrders=this.bs.getWorkOrders(); will work

workOrders is of type Observable. data is of type IWorkOrders[] Since those are 2 different types, thus error you are getting. You cannot assign IWorkOrders[] to Observable.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular/RxJS type error when mapping observable

Show loading indicator in Angular while waiting for a RxJS observable

Angular 12/Typescript/rxjs: error handling of nested Promises and rxjs Observable

Angular / RxJS Multicasting Observable of Observable

Angular/RxJS: synchronous observable

RXJS/Angular Replace Observable

RxJS Observable merge angular

Error constructing an rxjs/Observable

How to keep observable alive after error in RxJS 6 and Angular 6

swagger codegen --> angular6: rxjs observable compile error

Angular 6 / RxJs 6 Observable merging that also skips to error block

How to nicely throw an error to an Angular RXJS Observable subscriber

Angular loading service with rxjs

Angular2 RxJS getting 'Observable_1.Observable.fromEvent is not a function' error

RxJS wait for second observable then retry original observable on error - TypeScript/Angular 2

How to handle error and return observable while subscribe inside an observable function in Rxjs Angular

Angular - RxJS - Observable and method return

subscribe keys of and observable in Angular/RxJS

Angular rxjs mix observable and promises

Returning a Property from Observable as Observable in Rxjs Angular

Error rxjs_Observable__.Observable.forkJoin is not a function?

RxJS typing error missing Observable

throw error inside rxjs Observable

Rxjs in nestjs - Observable subscription error

Type Error: observable.of is not a function - [email protected] - [email protected] - angular5

rxjs+angular: errors "killing" the observable after error in web service call

How to import map property of rxjs in angular project , Error : Property 'map' does not exist on type 'Observable<Object>'?

TypeScript Observable Error While Trying to Make Multiple Requests to an API (Angular, TypeScript, RxJS)

Error in Angular and RXJS promise