Reputation: 25542
Is there a way in Express.js/Node to disable the view engine and only return JSON? The app I am working on will always return JSON
Upvotes: 1
Views: 322
Reputation: 650
var jsonData = [{
"id": 1,
"email": "[email protected]"
},{
"id": 2,
"email": "[email protected]"
}];
and do this res.json(jsonData)
, you don’t need any view engine.
Sample code:
var express = require('express'),
router = express.Router();
router.get('/api/users', function(req, res){
res.json(jsonData);
});
Upvotes: 1