Error: No default engine was specified and no extension was provided

The res.render stuff will throw an error if you’re not using a view engine.

If you just want to serve json replace the res.render('error', { error: err }); lines in your code with:

res.json({ error: err })

PS: People usually also have message in the returned object:

res.status(err.status || 500);
res.json({
  message: err.message,
  error: err
});

Leave a Comment