TS2339 : Property totalPages doesnt exist on type Object

dEs12ZER

i'm working in a simple application with angular5 , i have a page which returns the lists of some projects information using an API Restful with spring boot .

everything goes well , but i can't get that working while trying to use Pagination following a tutorial in youtube .

this is the method where i get an error

        pageProjects:any;
        pages:Array<number>;

    ngOnInit() {

        this.projetSevice.getProjects(this.currentPage,this.size)
          .subscribe(data=>{
            this.pageProjects=data;
            this.pages=new Array(data.totalPages);
          },err=>{
            console.log('this is error');
          })
  }

i get this error :

   TS2339 : Property totalPages doesnt exist on type Object

how can i resolve this ? thank you in advance .

Sajeetharan

This is because Typescript compiler checks that data variable. To fix this explicitly tell TypeScript type of data as any ,

this.projetSevice.getProjects(this.currentPage,this.size)
          .subscribe((data:any)=>{

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related