Couldn't show the response in JSON while using stored procedure.
I'm using express4-tedious to fetch results. It works fine if I use the select query but if I use the same with the stored procedure I don't know how to bind it in JSON.
The response screen is blank as I couldn't get the results.
var tediousExpress = require('express4-tedious');
var TYPES = require('tedious').TYPES;
var router = express.Router();
router.get('/:id', function (req, res) {
req.sql("exec GETDataOfEmployee @id")
.param('id', req.params.id, TYPES.VarChar)
.exec(res)
});
Any suggestions would be of great help.
This is what I would use:
var tediousExpress = require('express4-tedious');
var TYPES = require('tedious').TYPES;
var router = express.Router();
router.get('/:id', function (req, res) {
res.setHeader("Content-Type", "application/json");
req.sql("exec GETDataOfEmployee @id")
.param('id', req.params.id, TYPES.VarChar)
.into(res, '{}')
});
Do you have the this at the end of your SQL query in your stored procedure?:
for json path, without_array_wrapper