You've already forked DataMate
init datamate
This commit is contained in:
18
frontend/src/mock/mock-middleware/send-json-middleawre.cjs
Normal file
18
frontend/src/mock/mock-middleware/send-json-middleawre.cjs
Normal file
@@ -0,0 +1,18 @@
|
||||
const sendJSON = (req, res, next) => {
|
||||
res.sendJSON = (
|
||||
data = null,
|
||||
{ code = '0', msg = 'success', statusCode = 200, timeout = 0 } = {}
|
||||
) => {
|
||||
const timer = setTimeout(() => {
|
||||
res.status(statusCode).json({
|
||||
code,
|
||||
msg,
|
||||
data,
|
||||
});
|
||||
clearTimeout(timer);
|
||||
}, timeout);
|
||||
};
|
||||
next();
|
||||
};
|
||||
|
||||
module.exports = sendJSON;
|
||||
Reference in New Issue
Block a user