0
Whenever I try to add data the SQLITE table appears this error. Someone helps me, pfv. I’m starting at the Back-end now ;-;
const Database = require("../db/config")
module.exports = {
async create(req, res){
const db = await Database()
const pass = req.body.password
let roomId
/* Gera o numero da sala */
for(var i = 0; i < 6; i++){
i == 0 ? roomId = Math.floor(Math.random() * 10).toString() :
roomId += Math.floor(Math.random() * 10).toString()
}
/* Inseri a sala no banco */
await db.run(`INSERT INTO rooms (
id,
pass
) VAlUES (
${parseInt(roomId)},
${pass}
)`)
await db.close()
res.redirect(`/room/${roomId}`)
}
}
The error message (which you put in picture but should have put as text in question) says that
db
isundefined
. Apparently,await Database()
does not return anything. You need to see the code of this file.– Rafael Tavares
I managed to solve, I redid my config file following the same logic and it worked. Anyway...kkkk will understand. But thanks for the help :)
– gabriel Reis