I have a custom service running in Backendless Cloud.
I am using
Backendless.UserService.getCurrentUser()
thinking that this would return the user who invoked the service but I just get null.
The service is being called from the JS API like this:
Backendless.APIServices.invoke('sharedPosts', 'transormPost', id)
Is there a way to get the user object of the user who invoked the service?
Hi Tony,
Is there a logged in Backendless user in the app/service/program that invokes the sharedPosts
service?
Regards,
Mark
Hi Mark,
Yes the service is being invoked by a logged in user from the JS API.
Try the following to get the userId
in your Cloud Code:
this.request.context.userId
Then you can retrieve the actual object with:
currentUser = await Backendless.Data.of( "Users" ).findById( userId )
Please let me know if it worked.
Regards,
Mark
Hi Mark,
this.request.context.userId
worked in getting me the user id, so shouldn’t be a probably gettng the object from this now.
Thanks very much.
1 Like