Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Login 使用iron路由器登录meteor服务器端_Login_Meteor_Iron Router - Fatal编程技术网

Login 使用iron路由器登录meteor服务器端

Login 使用iron路由器登录meteor服务器端,login,meteor,iron-router,Login,Meteor,Iron Router,我想创建一个服务器端登录,为我的客户端应用程序使用iron router:server。 但直到现在我还没有找到任何线索。然而,我使用reststop2,但现在他说使用铁路由器 这是我的简单代码: Router.route('/api/signin', {where: 'server'}) .get(function () { this.response.end('get request\n'); }) .post(function () {

我想创建一个服务器端登录,为我的客户端应用程序使用iron router:server。 但直到现在我还没有找到任何线索。然而,我使用reststop2,但现在他说使用铁路由器

这是我的简单代码:

Router.route('/api/signin', {where: 'server'})
    .get(function () {
        this.response.end('get request\n');
    })
    .post(function () {
        console.log(this.request.body.username);//or email maybe
        console.log(this.request.body.password);
        this.response.end('post request\n');
    });
我使用json从body发送或发布数据,这就是为什么我使用
this.request.body.*

现在让我知道,如何使用该用户名和密码登录服务器端

仅供参考,在reststop2中,我只需使用
localhost:3000/api/login
并发送数据用户名和密码,然后获得return
access-token
user-id


谢谢

您可以使用iron:router构建API:

Router.map(function () {
    this.route('/api/login/:username/:password', {
        where : 'server,
        action : function(){
            //your code goes here
        }
    }
});

我总是会选择一个实现API的包,而不是iron:router,但对于简单的服务器端内容,iron:route可以做到。

我发布了一个开源包,用于在Meteor 0.9.0+中编写REST API,我想这可能正是您想要的。当RestStop2被弃用时,我遇到了同样的问题:

它的灵感来源于和使用的服务器端路由。如果您已经在使用RestStop2,那么很容易将其转换为