(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)
})
})
app.get('/users/:userId/books/:bookId', function (req, res) {
res.send(req.params)
})
await pool.query(`select distinct * from tenders where category = '${category}'`, (error,results,fields) => {
if(error) console.log(error)
resolve(results.map(r => r.creator))
})