Дай бог здоровья Андрею, помог отчистить кеш для отчета

This commit is contained in:
Кашин Максим 2023-12-28 14:23:04 +04:00
parent f70e94584e
commit 524c1f135a
3 changed files with 23 additions and 3 deletions

View File

@ -4,7 +4,14 @@
"id": 1,
"login": "admin",
"role": "admin",
"password": "admin"
"password": "admin",
"items": [
{
"id": 7,
"count": 5,
"bikeId": 8
}
]
},
{
"id": 2,
@ -116,10 +123,19 @@
"id": 7,
"dateTime": 2030,
"weight": 10,
"radius": 20,
"radius": 30,
"colorbike": "Красный",
"maxCount": 10,
"bikeId": 8
},
{
"dateTime": 2003,
"weight": 15.7,
"radius": 16.5,
"colorbike": "Жёлтый",
"maxCount": 10,
"bikeId": 7,
"id": 8
}
],
"bikes": [

View File

@ -3,6 +3,8 @@ const data = require('./data.json');
module.exports = (req, res, next) => {
if (req.url.startsWith('/search') && req.method === 'GET') {
try {
delete require.cache[require.resolve('./data.json')];
const data = require('./data.json');
const searchText = req.query.name;
const searched = data.products.filter(
(product) =>
@ -15,6 +17,8 @@ module.exports = (req, res, next) => {
}
} else if (req.url.startsWith('/report') && req.method === 'GET') {
try {
delete require.cache[require.resolve('./data.json')];
const data = require('./data.json');
// Добавляем фильтрацию по полю dateTime
const fromDate = req.query.fromDate;
const toDate = req.query.toDate;