diff --git a/lib/then.js b/lib/then.js index 731454a8..85d32116 100644 --- a/lib/then.js +++ b/lib/then.js @@ -11,11 +11,12 @@ Gun.chain.promise = function(cb) { }; // Returns a promise for the data, key of the gun call -Gun.chain.then = function() { +Gun.chain.then = function(cb) { var gun = this; - return (new Promise((res, rej)=>{ + var p = (new Promise((res, rej)=>{ gun.once(function (data, key) { res(data, key); //call resolve when data is returned }) })) + return cb ? p.then(cb) : p; };