lately I have been facing a connection problem that makes the connection between my code and db unstable...
As you may have noticed, that create a connection request error, and I need a way to make my Promise keep trying until resolve.
My code:
var results = sqlQuery(sql)
function sqlQuery (sql) {
return new Promise((resolve, reject) => {
sql.query(/*query*/, function (error, results, fields) {
if (error) {
console.log(error)
reject(error)
}
resolve(results)
})
})
}
IMPORTANT : The code above is inside a while() that change the /*query*/ in each loop