Accessing the store, e.g. users


(Kgish) #1

I was wondering what the standard way is in order for plugins to access the discourse user store, for example you want to display the avatar or other general information about a certain user.

var storeMain = api.container.lookup('store:main');
var users = storeMain.find('user');

However, this doesn’t work. Any other ideas?


(Robin Ward) #2

You should be able to fetch information about a user from the store like this:

store.find('user', 'eviltrout').then(u => console.log(u.get('avatar_template')));

(Kgish) #3

Yes that did the trick, thanks!!


(Robin Ward) #4