After entering my application my GlobalApplicationController initializes some services used through the whole application (like subscribing to sockets, etc.). It would be pretty handy to have a CurrentUser object - but I'm not sure about the object I get
@app.factory 'CurrentUser', ($http) ->
user = $http({
method: 'GET',
url: 'users/me'
}).then (data) ->
return data
The returned object contains a $$state object. To get to the actual data I need to call CurrentUser.$$state.value.data.
I want my service to be called like CurrentUser.email (or whatever attribute), but I have no idea what type this returned object is or why I'm getting it.
Edit: I've found out that the returned object I get is the $http object (due to coffeescript). Is there a way to return the data (not a promise)?