Answer the question
In order to leave comments, you need to log in
Why does a promise call the next then if the previous one doesn't return anything?
Hello. Can you please tell me why the promise is called, which follows after the promise of the user.get function, if the latter does not return anything?
var user = {
get: function() {
return new Promise(function(resolve, reject) {
setTimeout(resolve, 1000);
});
},
set: function() {
return new Promise(function(resolve, reject) {
setTimeout(resolve, 2000);
});
}
};
user.get().then(function() {
console.log(new Date(), "get");
}).then(function() {
console.log(new Date(), "set");
});
Answer the question
In order to leave comments, you need to log in
because that's how the chick's then call works:
it goes all the
way, and it doesn't matter if you return a promise (or whatever) or not
such a construction will first print "hello world", and then "undefined", because in the 2nd then we did not pass anything
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question