Math.floor(Math.random() * num) - num это результат умножения кол-ва родителей на кол-во блоков,в counter умножаю
Щитооо
function counter() {
let count = $('#counter').val()
for(i=0; i<count; i++) {
boxes.push(`<div class='item'>1</div>`)
}
$('#results').html(boxes)
boxes = []
}
(async function() {
const id = window.location.pathname.split('/')[2]
const response = await fetch(`/tender`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({id: id})
})
const data = await response.json()
console.log(data)
}())
app.get('/tender/:id', (req,res) => {
res.sendFile(`${static}/www/tender.html`)
})
app.post('/tender', (req,res) => {
console.log(req.body)
const tender = new Promise(async(resolve,reject) => {
await pool.query(`select * from tenders where id = '${req.body.id}'`, (error,results,fields) => {
resolve(results.map(r => r))
})
}).then(r => {
res.send(r)
})
})