node.js - javascript promise not passing all arguments (using Q) -


i having trouble passing arguments. promise callback receives 1 instead of three:

var asyncfunction= function(resolve) {     settimeout(function() {         resolve("some string passed", "and another", "third");     }, 1000); };  var promisefunction = function () {     var deferred = q.defer();      asyncfunction(deferred.resolve);      return deferred.promise; };  promisefunction().then(function() {     // 1 argument passed here instead of 3     // { '0': 'some string passed' }     console.log(arguments);  }); 

any idea doing wrong?

q promises can resolved 1 argument - promise stands 1 single value, not collection of them. put them in array explicitly if need multiple values. multiple-parameter-callbacks, can use .spread().


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -