[Solved] List all registered users

Hi, I know that this question is already solved all around the web but still, I can’t make it works. It only displays the current logged user instead of the full list. I’d be glad if someone tell me where I’m wrong because I’m stuck:

imports/ui/users-list.js:

import { Meteor } from 'meteor/meteor';
import { Template } from 'meteor/templating';
import '../api/users.js';
import './users-list.html';

Template.usersList.onCreated(() => {
    Meteor.subscribe('usersList');
});

Template.usersList.helpers({
    users(){
        return Meteor.users.find({});
    }
});

imports/ui/users-list.html:

<template name="usersList">
    <h2>users list</h2>
    {{#each users}}
        {{username}}
    {{/each}}
</template>

imports/api/users.js:

import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';

if (Meteor.isServer) {
    Meteor.publish('usersList', () => {
        return Meteor.users.find({},{fields: {username: 1}});
    });
}

This file above seems to have no effect, I can write {fields: {lmfao: 1}} instead and I still have the same result (only the current user name)

client/routes.js:

import '../imports/ui/app.js';

FlowRouter.route('/users-list', {
    name: 'users-list',
    action(params, queryParams) {
        BlazeLayout.render('app', {main: 'usersList'});
    }
});

Thank you

Do you do an import '../imports/api/users' anywhere in your /server/main.js?

Because otherwise that publication simply won’t run.

Oh boy… it works, thank you bro! :sweat_smile: