Ahhh ok, that makes sense. You are correct, it is returning an array of type Headers. Thank you very much!
Ronnie On Fri, Feb 19, 2021, 15:10 Arnaud Deman <[email protected]> wrote: > Hi Ronald, > > I think the backend is returning an array of header and not a single > instance (and there is no children property in an array). > You can see what is returned in the console : > forkJoin ([mainHeaders, subHeaders]). subscribe (results => { > console.log ('results', results); > results [0] .children = results [1]; > }) > > The take operator can also be useful in some cases: > forkJoin ([mainHeaders, subHeaders]). smoking pipe ( > tap (result => console.log ('results', results) > ) .subscribe (results => { > results [0] .children = results [1]; > }) > > NB: there may be typos > > Regards, > Arnaud. > > On Friday, 19 February 2021 at 20:49:01 UTC+1 [email protected] wrote: > >> I am getting an error that says "property does not exist on type" but the >> property does exist. I am trying to use a forkJoin. Here is the code for >> that: >> >> getCombined() { >> >> let mainHeaders = >> this.http.get<Header[]>(`${this.backendUrl}/api/header`); >> >> let subHeaders = >> this.http.get<Children[]>(`${this.backendUrl}/api/header/children`) >> >> forkJoin([mainHeaders, subHeaders]).subscribe(results => { >> results[0].children = results[1]; >> }) >> } >> >> It says "property 'children' does not exist on type 'Header[]' but here >> is my header definition: >> >> export class Header{ >> headerID: number; >> headerName: string; >> hidden: boolean; >> children: Array<any>; >> } >> >> I have also tried: >> >> import { Children } from '../definitions/children'; >> >> export class Header{ >> headerID: number; >> headerName: string; >> hidden: boolean; >> children: Array<Children>; >> } >> >> Also: >> >> children: Children; >> >> and >> >> children: Children[]; >> >> in the above class. >> >> What am I missing? >> >> Thank you in advance for any assistance! >> >> Ronnie >> > -- > You received this message because you are subscribed to the Google Groups > "Angular and AngularJS discussion" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/angular/fd3ae297-d402-4b57-bacd-948c1cb3a3a0n%40googlegroups.com > <https://groups.google.com/d/msgid/angular/fd3ae297-d402-4b57-bacd-948c1cb3a3a0n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/CADEEcDQqtDn-Jn3429Z23PFpf7coMsn9%3DmFZv9Ra0Or1mzaD8w%40mail.gmail.com.
