Throws this error because there is no testSecond on testFirst . If you want to do something after Promises resolves, follow these steps:
var sample = new SampleObject(); Promise.join(sample.testFirst(), sample.testSecond()).spread(function (testFirst, testSecond){
If you want to check if they are resolved correctly, instead of executing console.log, return the line in the testFirst and testSecond and register them in the spread callback, as shown below:
SampleObject.prototype.testFirst = function() { return this._ready.then(function() { return 'test_first'; }); } SampleObject.prototype.testSecond = function() { return this._ready.then(function() { return 'test_second'; }); }
Now, by running console.log in the spread callback, as shown below, it will write the lines returned by Promises above:
Promise.join(sample.testFirst(), sample.testSecond()).spread(function(first, second){ console.log(first);
source share