json-server
allows one to configure responses to be delayed via the command line:
json-server --port 4000 --delay 1000 db.json
How does one try to do this when using json-server
as a module? The following doesn't work:
const jsonServer = require('json-server')
var server = jsonServer.create();
server.use(jsonServer.defaults());
server.use(jsonServer.router("db.json"));
server.use(function(req, res, next) {
setTimeout(next, 1000);
});
server.listen(4000);
It just ignores the setTimeout
function completely and doesn't execute it.