Added better error handling into put

This commit is contained in:
Jachen Duschletta 2019-09-28 20:59:35 -07:00 committed by GitHub
parent 93cd24caa7
commit 6f2c246146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
/* Promise Library v1.0 for GUN DB
/* Promise Library v1.1 for GUN DB
* Turn any part of a gun chain into a promise, that you can then use
* .then().catch() pattern.
* In normal gun doing var item = gun.get('someKey'), gun returns a reference
@ -67,7 +67,7 @@ Gun.chain.promPut = async function (item, opt) {
var gun = this;
return (new Promise((res, rej)=>{
gun.put(item, function(ack) {
if(ack.err){rej(ack.err)}
if(ack.err){console.log(ack.err); ack.ok=-1; res({ref:gun, ack:ack})}
res({ref:gun, ack:ack});
}, opt);
}))