You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
I have a get API that queries a database and returns details abut the parameter supplied. Below is the code the returns a recordset saved in result variable
router.get('/:examno', (req, res) => {
var request = new sql.Request();
// query to the database and get the records
request.input('examno', sql.NVARCHAR, req.params.examno);
request.execute('dbo.spGetCandidatesDetails', function (err, result) {
if (err) console.log('Error in retrieving Candidate : ' + JSON.stringify(err, undefined, 2));
// send records as a response
res.send(result);
});
});
I have a get API that queries a database and returns details abut the parameter supplied. Below is the code the returns a recordset saved in result variable
router.get('/:examno', (req, res) => {
var request = new sql.Request();
// query to the database and get the records
request.input('examno', sql.NVARCHAR, req.params.examno);
request.execute('dbo.spGetCandidatesDetails', function (err, result) {
if (err) console.log('Error in retrieving Candidate : ' + JSON.stringify(err, undefined, 2));
// send records as a response
res.send(result);
});
});
The recordset returns this in JSON
allabs4limp if I understand the ask correctly. I believe you would want something like this result['recordset'] this would result in the array below.
[
{
"CandidateID": 1,
"CandidateExamNo": "12345",
"CandidateSubjectCombination": "1:2:3:4",
"CandidateToken": "7e7b3055-0c5b-47b2-81ae-0815cef16e9d",
"CandidateName": "Testing Testing Microphone"
}
]
I have a get API that queries a database and returns details abut the parameter supplied. Below is the code the returns a recordset saved in result variable
I have a get API that queries a database and returns details abut the parameter supplied. Below is the code the returns a recordset saved in result variable
router.get('/:examno', (req, res) => {
var request = new sql.Request();
// query to the database and get the records
request.input('examno', sql.NVARCHAR, req.params.examno);
request.execute('dbo.spGetCandidatesDetails', function (err, result) {
if (err) console.log('Error in retrieving Candidate : ' + JSON.stringify(err, undefined, 2));
res.send(result);
});
});
The recordset returns this in JSON
Now, i want to read the contents of the recordset into a variable to be able to have access to each of the field names in the recordset.
Thanks.
The text was updated successfully, but these errors were encountered: