Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to convert Object into any type in this situation

So I have the following problem, I need to pass the data Object into this method but the problem is that it says it doesn’t have the hits property, usually I would just do (data:any) but since I also need the news data I can’t, any way to solve this?

public getDataByPage(contentType: string, pageNum: number): void {
    this.http.get(`https://hn.algolia.com/api/v1/search_by_date?query=${contentType}&page=${pageNum}&hitsPerPage=16`).pipe(
      take(1),
      withLatestFrom(this.news$),
      tap(([data, news]) =>{
        this.parseNewsData([...news, ...data.hits]);
      })
    ).subscribe();
  };

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

this.parseNewsData([...news, ...(data as any).hits]);

Does this solve you problem?

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading