Problem when trying to obtain users


I am using NativeScript with Angular 2 and Typescript. When I am trying to run this code

const query = new Kinvey.Query();
query.equalTo('username', 'Vasilev');
Kinvey.User.lookup(query).subscribe((users: Kinvey.User[]) => {
     // ...

… I am getting the error: error TS2339: Property ‘subscribe’ does not exist on type ‘Promise<{}>’.

Any ideas?


Looks like lookup returns a Promise, not an Observable. You could fi use rxjs to convert it to an Observable though (fromPromise comes to mind).

Did you see this example somewhere online?


I saw this example in the Kinvey`s devcenter here:

Maybe this is a mistake?


Indeed, you code is equal to that example so you’d need to look at the Kinvey sources to see if lookup actually returns a Promise or an Observable. I’m not currently a Kinvey user so dunno by heart.