In some cases I have noticed that getCurrentUserProfileData() and getUserProfileData() functions return null data while the user profile has all users data set and ready! When I searched more about the issue I've found that the REST web service is not getting connected with the user profile due to an incorrect configuration in the SharePoint user profile.
In order to solve this you need to follow these steps:
- Open the central administration
- Click on Service Applications
- Click on User Profile Service Application
- Click on Setup My Sites
- Fill in the My Site Host location the correct url , if it is empty or not correct the REST web services will not connect to the User Profile service.
- Click OK button and test again and it should work.