var express = require('express');
var router = express.Router();
var Questionnaire = require('../models/questionnaire');
router.get('/', function(req, res, next) {
Questionnaire.find().sort('username').exec(function(error, results) {
if (error) {
return next(error);
}
res.json(results);
});
});
router.get('/:questionnaireId', function(req, res, next){
Questionnaire
.where({username: req.params.questionnaireId}, {featured: true})
.where({featured: true})
.exec(function(error, results){
if (error) {
return next(error);
}
if (!results) {
res.send(404);
}
res.json(results);
});
});
module.exports = router;
In the case of the "no result" scenario in Express, how can I display a selection error message in the browser without displaying an empty array []. Each time I run a query using the Express platform, my browser always displays this empty array [] when the result is not found or the user is not found. How can I get around this?
source
share