简体   繁体   中英

Meteor: Call server-side method by client

I'm creating a new user with Accounts.createUser() on client side in a Admin-Frontend. This works, but after creating the user, there is a auto-login, which is very logic, as the input has be done on client side. But I want to create new users by an admin-account on frontend.

So I thought about creating a server-method, calling from client. But that doesn't work:

server.js

Meteor.methods({
    'createUserByAdmin': function(){
        console.log("Hello world");
        // Create user here
    }
});

client.js

Template.users.events({
    'submit form': function(event) {
        event.preventDefault();
        Meteor.call('createUserByAdmin');
    }
});

Now I would expect by submiting the form there should be "Hello world" on the console. But I don't get anything.

您必须查看服务器控制台。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM