javascript - pass var to routes - node.js -
i have problem passing object through route, server.js
var jwt = require('jsonwebtoken'); var socketiojwt = require('socketio-jwt'); var app = require('koa')(); var server = require('http').createserver(app.callback()); var io = require('socket.io')(server); var socket = require('./api/lib/socket.js')(app,io,socketiojwt); var router = require('./api/router'); app.use(views('views', {map:{html:'swig'}})); router(app,jwt);
this routes.js
var route = require('koa-route'); module.exports = function router(app,jwt) { app.use(route.post('/login/auth', require('./routes/auth')(jwt)); };
and auth:
module.exports = function *(jwt) { var profile = { first_name: 'a', last_name: 'b', email: 'a@gb.com', id: 0 }; var input = this.request.body; var token = jwt.sign(profile, input.password, { expiresin: 60*5 }); this.cookies.set('access_token', token, { signed: false }); this.body = token; };
the problem passing jet get: status code must number
error?
Comments
Post a Comment