How to get the current user asynchronously using the JavaScript API ?

Hello
I want to get the current user asynchronously using the JavaScript API.
I used the ‘getCurrentUser()’ but it is synchronous so I found the ‘getCurrentUser<Promise>()’.
Thanks.

Hi Sofienne,
Please, provide us the code example to reproduce your issue.
Regards, Ilya

Hello
Thank you for replying

        let currentUser = Backendless.UserService.getCurrentUser()

This return a synchronous response (‘User’ object).
I want to find another solution asynchronously.

Ok. It seems I guessed what is the problem. We’ll fix it and notify you about it here. Stay tune.
Regards, Ilya

Thank you.

Please, update your Backendless JS-SDK up to version 3.1.17.
Now you can use next call signature for getCurrentUser

Backendless.UserService.getCurrentUser(new Backendless.Async(function(currentUser){...}, onError))

Regards, Ilya

Thank you for this
You have done it for me it is really kind from you.
But it is not my birthday today :stuck_out_tongue:
Best regards.

:slight_smile: Did it help you?

Definitively yes, it worked.
Thank you very much you fixed the issue.

The story is that I am developing an Angular 2 application, in the when I try to get data for a specific user I needed to use the ‘Backendless.UserService.getCurrentUser()’, I am getting the data asynchronously using the ‘Backendless.Async’ but I was getting the user synchronously so in the browser console shows the error (Warning) ‘More task executed than were scheduled’ getting the user was executed in the main thread.

But after using ‘getCurrentUser(async?:Backendless.Async)’ the error disappeared because it is not running on the main thread.

So thank you very, very, very, very much for the huge work and support!
(Sorry for my english mistaks).

Best regards.