2
Good morning, I need help with my Password, when recording my information in indexDB I am using . then to write on the console, but this . then is not fired.
I noticed that my Promise gets pending status and I don’t know if it has to be.
//codigo executado no console
const negociacao = new Negociacao( new Date(), 7, 100);
ConnectionFactory
.getConnection()
.then(conn => new NegociacaoDAO(conn))
.then(dao => dao.adiciona(negociacao))
.then(() => console.log('sucess'))
.catch(err => console.log(err));
the Tradeable class is the class responsible for adding the items in the indexDB and returning this class
class NegociacaoDAO{
constructor(connection){
this._connection = connection;
this._store = 'negociacoes';
}
adiciona(negociacao){
return new Promise( (resolve, reject)=>{
const request = this._connection
.transaction([this._store], 'readwrite')
.objectStore(this._store)
.add(negociacao);
request.onsucess = e => resolve(e.target.result);
request.onerror = e => {
console.log(e.target.error);
reject('Não foi possivel salvar a negociação');
}
});
}
request.onsucess
would not berequest.onsuccess
?– Artur Trapp
Thank you Artur, I’m a beginner and since yesterday I have this problem.
– Willian Carlos
No problem. If this solved your problem, be sure to accept the answer.
– Artur Trapp