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

error TS2339: Property 'value' does not exist on type 'Object'

TS2339: Property 'map' does not exist on type 'Object'

error TS2339: Property 'email' does not exist on type 'Object'

error TS2339: Property 'json' does not exist on type 'Object'

TS2339: Property 'name' does not exist on type 'object'

Angular : error TS2339: Property 'data' does not exist on type 'Object

Angular - error TS2339: Property 'results' does not exist on type 'Object'

TS2339: Property 'id' does not exist on type '{}'

"TS2339: Property ... does not exist on type ...", on input field

error TS2339: Property 'data' does not exist on type 'TaskInterface[]'

error TS2339: Property 'subscribe' does not exist on type '{}'

TS2339: Property 'props' does not exist on type 'Home'

error TS2339: Property 'num' does not exist on type 'CustomerTransfert[]'

TS2339: Property 'SOLDE' does not exist on type 'AdvTitres'

error TS2339: Property 'loading' does not exist on type 'DiseaseListComponent'

TS2339: Property 'whyDidYouRender' does not exist on type 'FC<ButtonProps>'

error TS2339: Property 'title' does not exist on type '{}'

TS2339: Property 'includes' does not exist on type 'string'

TS2339: Property 'style' does not exist on type 'Element'?

error TS2339: Property 'results' does not exist on type 'Response'

error TS2339: Property 'for' does not exist on type 'HTMLProps<HTMLLabelElement>'

error TS2339: Property 'x' does not exist on type 'Y'

Typescript: Arrow function - TS2339: Property does not exist on type '{}'

Property 'userid' does not exist on type '{ }'. TS2339

error TS2339: Property 'endsWith' does not exist on type 'string'

TS2339: Property 'users' does not exist on type '{}'

TS2339: Property 'style' does not exist on type 'Element'

Error TS2339: Property 'router' does not exist on type 'HomePage'

TS2339: Property 'props' does not exist on type '{}'