i'm having troubles with an event function with IndexxDB, it works well, but it dosen't modify the "success" var, this is my code, the function returns an undefined value, the request.onsuccess works well and modify the var "success" inside that function, but outside the function "success" is undefined, is there a way to assing a value to "success" or another way to return a boolean?
nuevoCliente = function(cliente){
//works well
let transaction = this.DB.transaction(['cliente'],'readwrite')
let objectStore = transaction.objectStore('cliente')
let request = objectStore.add(cliente)
//works well
let success
request.onsuccess = function() {
success = true
console.log(success) //here the value is true and its called
}
request.onerror = function() {
success = false
console.log(success) //this command isn't called
}
console.log(success)//here the value is undefined
return success //returns undefined
}