koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 118 forks source link

Getting req.body from POST Body occurs an Error " stream.on is not a function when using turbo-http #119

Closed nassirdreffy closed 5 years ago

nassirdreffy commented 5 years ago

const bodyParser = require('body-parser'); const server = require('restana/libs/turbo-http') const router = require('find-my-way') const routerFactory = (options) => {return router(options)}

const service = require('restana')({routerFactory, server* }); //server occurs an error:

{ "errClass": "TypeError", "code": 500, "message": "stream.on is not a function" }

service.start(3000) service.use(bodyParser.json()); service.use(bodyParser.urlencoded({extended:true}));

service.get('/', async (req, res) => { res.send("Hello World"); }); service.get('/user/:id', async (req, res) => { res.send("User ID: " + req.params.id); }); service.post('/user', async (req, res) => { res.send(req.body.name); });

/#################################################################

Regards

dead-horse commented 5 years ago

hi, I'm not sure if koa-bodyparser can work with restana. If you want to investigate the error, you should first look at the error stack to find where the error occured.