Problem when trying to obtain users


#1

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?


#2

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?


#3

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

https://devcenter.kinvey.com/nativescript/guides/users#lookup

Maybe this is a mistake?


#4

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.