პრომისები ჯაჭვის შიგნით JavaScript-ში
ჯაჭვის ფუნქციებს ასევე შეუძლიათ პრომისების დაბრუნება.
ამ შემთხვევაში ამ პრომისის შედეგი გადავა
შემდეგ then-ში:
promise.then(
function(result) {
return result + '1';
}
).then(
function(result) {
return new Promise(function(resolve) {
resolve(result + '2'); // ეს შედეგი გადავა შემდეგ then-ში
});
}
).then(
function(result) {
return result + '3';
}
).then(
function(result) {
console.log(result); // გამოიტანს 'string123'
}
);