poimsm2
poimsm2

Reputation: 572

Property 'then' does not exist on type '() => Promise<{}>'. - Ionic 3

Method

  hola() {
        return new Promise((resolve, reject) => {
          if(true) {
            resolve(true)
          }
        })
    }

Calling the method

this.hola.then(data => console.log(data));

Error

Property 'then' does not exist on type '() => Promise<{}>'.

I already tried to restart ionic serve but it keeps throwing that error

Upvotes: 12

Views: 18772

Answers (2)

arun kumar
arun kumar

Reputation: 591

The parenthesis is missing while you are calling the method hola.

this.hola().then(data => console.log(data));

Upvotes: 31

a big expert
a big expert

Reputation: 21

When you call the method, try this instead, storring it in a variable of type "any" makes it ignore the "existence" of the proprety

    var a:any = this.slides.getActiveIndex()
    a.then(data => {
        console.log(data)
    })

Upvotes: 2

Related Questions