I'm encountering an issue with knex.js
and express
. Here is the code snippet in question:
userRouter.get('/:userId', function (req, res) {
DB('users').where({
id: req.params.userId
}).first('name').pipe(res);
});
According to the knex.js
documentation, there is a stream interface for knex.js query.
However, I am unable to pipe the result to the express(node http api)
response.
The code mentioned above is not functioning correctly.
An error message "TypeError" is being displayed:
TypeError: first argument must be a string or Buffer
What could have caused this issue?