learning express step(十四)
learning express error handle
code:
const express = require('express'); const app = express(); const fs = require('fs'); app.get('/', function (req, res, next){ fs.readFile('file', function (err, data) { if(err){ next(err) }else{ res.send(data); } }); }); app.listen(3000);
result: